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/102580.html below:

[Python-Dev] unexpected import behaviour

[Python-Dev] unexpected import behaviour [Python-Dev] unexpected import behaviourNick Coghlan ncoghlan at gmail.com
Sat Jul 31 03:06:42 CEST 2010
On Sat, Jul 31, 2010 at 4:46 AM, Daniel Waterworth
<da.waterworth at gmail.com> wrote:
> Having thought it through thoroughly, my preference is for a warning.

That's actually harder than it sounds.

Inserting "__main__" into sys.modules under its normal name as well as
"__main__" is actually pretty easy (for both direct execution and -m).
Making it generate a warning when accessing __main__ under its normal
name is trickier (akin to the various "lazy module loading" hacks that
are available in assorted packages on pypi).

Extending this to work for arbitrary objects is very hard to do
efficiently (you'd almost certainly need an additional index from
__file__ values to sys.modules keys that would complain whenever the
list of associated key entries for a given __file__ value contained
more than 1 entry). That's a lot of infrastructure just to try and
detect a fairly rare kind of bug.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
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