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:
implied here is that you restructure...
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__'
You see, we're further assuming you've structured the module for this
purpose. IOW, your module should end with:
if __name__ == '__main__':
main()
and nothing more. Then, you can do:
import db_test
db_test.main()
Emile
--
http://mail.python.org/mailman/listinfo/python-list