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

2009-07-12 Thread Emile van Sebille
On 7/12/2009 11:13 AM Stef Mientki said... SM> if __name__ == '__main__': SM>import db_test SM>new_globals = {} SM>new_globals [ '__name__' ] = '__main__' SM>new_globals [ '__file__' ] = 'not really valuable' SM>execfile ( 'db_test.py', new_globals ) Why not: implie

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

2009-07-12 Thread Aahz
In article , Stef Mientki wrote: >Stef deleted an attribution: >> >> Why not: >> >> import db_test >> db_test.main() > >Yes I tried that too, but it gives the following error: "module object >not callable" You need to create a main() function in db_test first. -- Aahz (a...@pythoncraft.com)

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

2009-07-12 Thread Stef Mientki
SM> if __name__ == '__main__': SM>import db_test SM>new_globals = {} SM>new_globals [ '__name__' ] = '__main__' SM>new_globals [ '__file__' ] = 'not really valuable' SM>execfile ( 'db_test.py', new_globals ) Why not: import db_test db_test.main() I think that is what

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

2009-07-12 Thread Piet van Oostrum
> Stef Mientki (SM) wrote: >SM> Stef Mientki wrote: >>> hello, >>> >>> 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 the library is simply, >

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

2009-07-12 Thread Aahz
In article , Stef Mientki 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 te

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

2009-07-12 Thread Stef Mientki
Stef Mientki wrote: hello, 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 the library is simply, I add a main section to the library, so no problem. But if the library r

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

2009-07-12 Thread Stef Mientki
hello, 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 the library is simply, I add a main section to the library, so no problem. But if the library requires a lot of over