A mistake which almost went me mad

Random832 random832 at fastmail.com
Mon Mar 7 11:28:13 EST 2016


On Mon, Mar 7, 2016, at 11:19, Ian Kelly wrote:
> Relative imports only work inside packages. You can't use a relative
> import to import one top-level module from another.
> 
> Besides, the relative import doesn't help to disambiguate in this
> case. The absolute path of the stdlib email module is "email". The
> absolute path of the module in your CWD is also "email". Why should a
> relative import prefer one over the other? So I would think that even
> if it worked, it would still just end up importing the first one it
> finds on your sys.path.

Maybe what we need is a system smarter than sys.path - a clear "import
from stdlib" statement, and a way to designate what directories *contain
stdlib modules*, would be useful.



More information about the Python-list mailing list