how to run the "main" section of another module ?
Stef Mientki
stef.mientki at gmail.com
Sun Jul 12 14:13:53 EDT 2009
>> 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.
>
>
Yes I tried that too,
but it gives the following error:
"module object not callable"
db_text.__main__()
gives error:
'module' object has no attribute '__main__'
cheers,
Stef
More information about the Python-list
mailing list