Brett Cannon added the comment:

So those semantics have existed as long as PEP 302 has been around, which is 
Python 2.3 (that PEP itself is over a decade old), so changing them now would 
break code.

And honestly I wouldn't change it anyway. On some filesystems, stat calls are 
extremely costly (e.g. NFS). Even if it was only on failed imports it would 
still have a cost. And considering a way to stay compatible between Python 2 
and 3 is to catch ImportError and then import a module whose named changed, it 
would still be a costly change.

Now if you personally really want the semantics you are after you could have a 
sys.meta_path importer which cleared out sys.path_importer_cache and tried the 
import again.

As for documentation, it's explained in the language reference: 
http://docs.python.org/3/reference/import.html#path-entry-finders . But 
otherwise there isn't another place unless someone writes a HOWTO on this, but 
that probably isn't a good thing as import is something you really should be 
weary of mucking with. For someone trying to import the contents of a tarfile, 
they would be better served by a tarfile importer than unpacking the tarfile 
and then adding a path to sys.path. But someone has to write that tarfile 
importer first. =) Maybe some day: issue #17630.

----------
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20321>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to