Imported or executed?

Fredrik Lundh fredrik at pythonware.com
Wed Feb 16 14:17:14 EST 2005


Stephan Schulz wrote:

> Is there a (portable, standard) way for the program/module to find out
> if it is imported or executed stand-alone?

if a module is executed, it's name is set to "__main__".  see:

http://www.python.org/doc/faq/programming.html#how-do-i-find-the-current-module-name

</F> 






More information about the Python-list mailing list