Re: import overwrites __name__

2009-05-10 Thread Peter Otten
Piet van Oostrum wrote: >> Peter Otten <__pete...@web.de> (PO) wrote: > >>PO> Piet van Oostrum wrote: This is perfectly normal. > >>PO> I'm not 100% sure of that. > > Why not? What you quoted was not code I would /normally/ write. I was playing with the context and meaning of y

Re: import overwrites __name__

2009-05-10 Thread Piet van Oostrum
> Peter Otten <__pete...@web.de> (PO) wrote: >PO> Piet van Oostrum wrote: >>> >>> This is perfectly normal. >PO> I'm not 100% sure of that. Why not? >PO> Just in case you didn't notice: I'm not the OP. The above piece of junk >code >PO> was my attempt to keep as close to the code he pos

Re: Re: import overwrites __name__

2009-05-10 Thread Dave Angel
Scott David Daniels wrote: Piet van Oostrum wrote: Peter Otten <__pete...@web.de> (PO) wrote: PO> $ cat x.py PO> import sys PO> globals().update(zip(*(range(110),)*2)) PO> y = 42 PO> print __name__ PO> if __name__ == "__main__": PO> a = b = 42 PO> print len(dir()) PO> from x import y as z

Re: import overwrites __name__

2009-05-10 Thread Peter Otten
Piet van Oostrum wrote: >> Peter Otten <__pete...@web.de> (PO) wrote: > >>PO> $ cat x.py >>PO> import sys >>PO> globals().update(zip(*(range(110),)*2)) >>PO> y = 42 >>PO> print __name__ >>PO> if __name__ == "__main__": >>PO> a = b = 42 >>PO> print len(dir()) >>PO> from x import y as z >>P

Re: import overwrites __name__

2009-05-10 Thread Scott David Daniels
Piet van Oostrum wrote: Peter Otten <__pete...@web.de> (PO) wrote: PO> $ cat x.py PO> import sys PO> globals().update(zip(*(range(110),)*2)) PO> y = 42 PO> print __name__ PO> if __name__ == "__main__": PO> a = b = 42 PO> print len(dir()) PO> from x import y as z PO> try: PO> print my_n

Re: import overwrites __name__

2009-05-10 Thread Piet van Oostrum
> Peter Otten <__pete...@web.de> (PO) wrote: >PO> $ cat x.py >PO> import sys >PO> globals().update(zip(*(range(110),)*2)) >PO> y = 42 >PO> print __name__ >PO> if __name__ == "__main__": >PO> a = b = 42 >PO> print len(dir()) >PO> from x import y as z >PO> try: >PO> print my_name >PO> ex

Re: import overwrites __name__

2009-05-10 Thread Peter Otten
MRAB wrote: > 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

Re: import overwrites __name__

2009-05-09 Thread Scott David Daniels
Glenn Hutchings wrote: On Fri, 08 May 2009 19:14:52 +0200, Marco wrote: 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__

Re: import overwrites __name__

2009-05-09 Thread MRAB
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 __n

Re: import overwrites __name__

2009-05-08 Thread Dave Angel
Marco wrote: 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

Re: import overwrites __name__

2009-05-08 Thread Glenn Hutchings
On Fri, 08 May 2009 19:14:52 +0200, Marco wrote: > 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__

Re: import overwrites __name__

2009-05-08 Thread Stephen Hansen
> > > Still I appreciate if someone could explain me why. > We can't without seeing the code. There shouldn't be any difference, so if there is then its because your code is doing something to cause it-- break it down to a runnable example and we may be able to tell you why, giving us real code an

Re: import overwrites __name__

2009-05-08 Thread Marco
Stephen Hansen wrote: >> >> So what leads to the behavior that the .pyc is not created? >> > > PYC's are only generated on import, they're never made for the main > script. > > I personally like to keep my 'main script' very small. Largely just > something which imports other modules and sends

Re: import overwrites __name__

2009-05-08 Thread Stephen Hansen
> > So what leads to the behavior that the .pyc is not created? > PYC's are only generated on import, they're never made for the main script. I personally like to keep my 'main script' very small. Largely just something which imports other modules and sends them along on their business. --S --

Re: import overwrites __name__

2009-05-08 Thread Marco
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 impo

Re: import overwrites __name__

2009-05-08 Thread Marco
Terry Reedy wrote: > 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 >

Re: import overwrites __name__

2009-05-08 Thread Terry Reedy
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 __n

import overwrites __name__

2009-05-08 Thread Marco
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(d