[issue29929] Eliminate implicit __main__ relative imports

Ronald Oussoren report at bugs.python.org
Tue Jun 6 15:54:51 EDT 2017


Ronald Oussoren added the comment:

If only someone had access to the time machine keys to fix this 20 year ago :-(. Anything beyond that last option (recognising that the script tries to import itself under another name) is bound to run into odd issues or backward compatibility concerns.

Just recognising a reimport of __main__ should avoid a lot of confusion though, from what I've seen in discussions most cases of unintentional shadowing of the stdlib is caused by folks naming a exploratory script the same as a stdlib module (e.g. naming a script "socket.py" when experimenting with sockets).

W.r.t. "from . import ..." and scripts: installing using entry points isn't a problem, but installing using plain distutils still is as is the even more low-tech option of just copying files to the right location (maybe using a Makefile).  But that issue is moot now that Guido has stated he doesn't like the idea.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29929>
_______________________________________


More information about the Python-bugs-list mailing list