A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-July/101892.html below:

[Python-Dev] Peculiar import code in pickle.py

[Python-Dev] Peculiar import code in pickle.py [Python-Dev] Peculiar import code in pickle.pyAntoine Pitrou solipsis at pitrou.net
Tue Jul 13 17:34:18 CEST 2010
On Tue, 13 Jul 2010 11:25:23 -0400
Alexander Belopolsky <alexander.belopolsky at gmail.com> wrote:
> When pickle.py needs to import a module by name, it goes through a
> peculiar dance of
> 
>             __import__(module, level=0)
>             mod = sys.modules[module]
> 
> As far as I can tell, unless builtins.__import__ is overridden or
> sys.modules clobbered by user code, the above should be equivalent to
> 
>             mod = __import__(module, level=0)

Only for top-level modules:

>>> __import__("distutils.core", level=0)
<module 'distutils' from
'/home/antoine/py3k/__svn__/Lib/distutils/__init__.py'>
>>> sys.modules["distutils.core"]
<module 'distutils.core' from
'/home/antoine/py3k/__svn__/Lib/distutils/core.py'>


Regards

Antoine.


More information about the Python-Dev mailing list

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