Thank you for mentioning the old and related issue.
In order to prevent confusion, I want to point out that the primary scenario that I meant is not that the file imports itself but another file in the same directory with the name of a module that is also installed in site-packages. Not sure if I made that clear in my original post?
On Wed, Nov 3, 2021 at 4:30 PM Ned Batchelder firstname.lastname@example.org wrote:
On 11/2/21 6:03 AM, Florian Wetschoreck wrote:
The scenario/observation: Beginners sometimes create scripts with the name of a package e.g. pandas.py or seaborn.py in order to test something.
There's a previous discussion about preventing importing a file into itself. It's a common beginner mistake: "I want to try out the random module, I will name my test program random.py". Then they get a baffling error: "AttributeError: module 'random' has no attribute 'shuffle'". If we make the actual error more apparent ("ImportError: module 'random' imported itself"), we might nip this error in the bud.
Python-ideas mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://email@example.com/message/VVQRV5... Code of Conduct: http://python.org/psf/codeofconduct/