how to run the "main" section of another module ?

Aahz aahz at pythoncraft.com
Sun Jul 12 10:21:55 EDT 2009


In article <mailman.3028.1247406021.8015.python-list at python.org>,
Stef Mientki  <stef.mientki at gmail.com> wrote:
>
>when I''m working in a library, and want to test some of the library
>functions, I need to switch to a main application, (which has a normal
>main-section) and run that.

if __name__ == '__main__':
    main()

Then you can call main() from another module for testing purposes.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur."  --Red Adair



More information about the Python-list mailing list