On Monday 07 June 2004 01:21 pm, Jiwon Seo wrote: > It looks like it's because even if the package failed to be loaded, it > should be added to its parent module dict, IMHO. > The comment in the import.c::add_submodule describes the behavior. I > don't know how it could be useful, but I think it's the way import > behaves. This is to support caching; if some module in the "foo" package imports the "bar" module, and there isn't a "foo.bar" module, sys.modules grows a "foo.bar": None entry so that further attempts to import sys within the "foo" package don't have to do as much work to know that there isn't one, and can fall back to a top-level "bar" module (which can still fail if there isn't one). -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Zope Corporation
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4