Starting Python... some questions

Thinker thinker at
Tue Mar 13 06:00:19 CET 2007

Hash: SHA1

jezonthenet at wrote:
> I started using Python a couple of days ago - here are a few
> questions:
> * Doesn't the __main__() method automatically execute when I run my
> python program?
> * Only when I do an import of my file within python and then
> run test.__main__() I can see where my bugs are. Is this correct?
> (right now this is my only way of running my python program and see
> where I have problems)
> * Once I've done an import and then I wish to make a change to the
> file I've imported I have to quit Python, restart and import that
> module again in order for the module to be refreshed. Is there no "re-
> import" ?
> * Finally, could someone tell me why I'm having problems with the
> small module below?
> - Python pretends I provide chassis_id() with three parameters, even
> though I clearly only provide it with two - why?
No, Python is executing a module. You should explicit call __main__()
at top scope of
your module. For ex.

if __name__ == '__main__':

This snippet calls __main__() when the module is executed directly,
but not imported as a module.

Once a module had been imported, you should invoke reload() function
to reload it from filesystem.

- --
Thinker Li - thinker at at
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla -


More information about the Python-list mailing list