I actually didn't know that there were use cases for importing itself — thanks 
for letting me know.

The best way of implementing a better error message would probably be to change 
the message for when the user import itself, while it's still partially 
initialized.

In the beginning of the programming journey, getting a message about circular 
imports when they were testing out tkinter in a file names "tkinter.py" would 
probably not be helpful. Getting a message that hints that you may have 
accidentally imported itself, however, will probably help significantly.

Maybe an error like this would be better, even though the wording could be 
worked on:
"AttributeError: partially initialized module 'tkinter' has no attribute 'Tk' 
(most likely
due to trying to import the file that is being executed)"
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QOL54FGEDKYGX5J4UMBAUR74PGS3HEPD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to