import doesn't work as i want

Fredrik Lundh fredrik at
Mon Jan 31 11:05:54 EST 2005

Olivier Noblanc wrote:

> In the botom of this post you will see my source code.
> The problem is when i launch that doesn't make anything why ?

the "if __name__" statement checks the name of the module.  if you run
Python file as a script, by passing a filename to the python interpreter, the
__name__ variable is set to  "__main__".  if you import a file as a module,
the __name__ is the name of the module, not "__main__".

if you want to do something, move that code to (or move
it into a function, and call it from


More information about the Python-list mailing list