import overwrites __name__
Terry Reedy
tjreedy at udel.edu
Fri May 8 14:25:15 EDT 2009
Marco wrote:
> Hi,
>
> There happened something that I do not understand. Actually I don't even
> know how it can be possible.
>
> I import a module and then the name space of the importing module seems do
> be overwritten.
>
> my_name = __name__
> print my_name
> print len(dir())
> from x import y as z
> print __name__
> print len(dir())
> print my_name
>
> ->
> __main__
> 119
> x
> 117
> unhandled NameError "name 'my_name' is not defined"
>
> The module x is from me, and I am not aware of doing anything cruel there.
> What evil thing can be done in its sub module that can result in that
> strange thing?
see responses to "unicode bit me' thread
More information about the Python-list
mailing list