Re: question on "import __main__"

2005-08-26 Thread infidel
> import __main__ > if __name__!='__main__': >print 1 > > print 2 > > when i run test.py, i got > 2 > on the screen. > > now, i have some question about the code, 1. since no __main__ module at > all, why it's legal to write "import __main__"? __main__ is the module that the interpreter starts

Re: question on "import __main__"

2005-08-26 Thread Robert Kern
wen wrote: > i have written some code in test.py as below: > import __main__ > if __name__!='__main__': >print 1 > > print 2 > > when i run test.py, i got > 2 > on the screen. > > now, i have some question about the code, 1. since no __main__ module at > all, why it's legal to write "import

question on "import __main__"

2005-08-26 Thread wen
i have written some code in test.py as below: import __main__ if __name__!='__main__': print 1 print 2 when i run test.py, i got 2 on the screen. now, i have some question about the code, 1. since no __main__ module at all, why it's legal to write "import __main__"? 2. since if running a scr