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/101893.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.pyAlexander Belopolsky alexander.belopolsky at gmail.com
Tue Jul 13 17:46:11 CEST 2010
On Tue, Jul 13, 2010 at 11:34 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Tue, 13 Jul 2010 11:25:23 -0400
..
> 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'>

That's right, but I believe the recommended way to achieve that
behavior is to supply a dummy fromlist:

>>> __import__("distutils.core", fromlist=["dummy"], level=0)
<module 'distutils.core' from
'/Users/sasha/Work/python-svn/py3k/Lib/distutils/core.py'>

That's what C implementation does AFAICT.
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