On Sat, Jul 31, 2010 at 4:46 AM, Daniel Waterworth
<da.waterwo...@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   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to