>>>>> Stef Mientki <stef.mien...@gmail.com> (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, >>> I add a main section to the library, >>> so no problem. >>> >>> But if the library requires a lot of overhead, >>> I want to run some main program, >>> that has a main section, >>> and uses my library under construction. >>> >>> So how do I call from within the library module, >>> in a main section in that library module, >>> a main in another module ? >>> >>> thanks, >>> Stef Mientki >SM> btw, >SM> I just found this in one of my programs (which works but isn't very >SM> beautiful) >SM> In the library fill under construction I put this main section: >SM> (sb_test.py is the main program, that has a main section and uses the >SM> library under construction) >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 Aahz meant. -- Piet van Oostrum <p...@cs.uu.nl> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list