some basic questions...

Russell Blau russblau at hotmail.com
Mon Sep 20 18:53:09 CEST 2004


"Player" <guess at My.email.address.scum.com> wrote in message
news:cimv3o$a51$1 at newsg2.svr.pol.co.uk...
>
> [book quote]
> When a file containing python code is executed, the built in variable
_name_
> is populated with the name of the module being executed. If the value of
> _name_ is _main_, then that file is the original file that was used to
> invoke the application from command line or an icon.
> This is usefull, as it allows code to know the difference between when it
is
> invoked & when it is imported by another python program. It is also
provides
> a convenient place to provide one-time startup code.
> [end quote]

Actually it is '__name__' and '__main__', with *two* _ characters both
before and after.  You need to be careful about the underscores when using
built-in names like these, because typing them with just one _ will not work
at all!

As for how to use __name__ and the importing modules question, I suggest you
read http://www.python.org/doc/current/tut/node8.html


-- 
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.





More information about the Python-list mailing list