main logo
Subject: Re: [dabo-dev] The problem with __name__
Author: Paul McNett

Posted: 2004/10/31 16:39:35
 
View Entire Thread
New Search


Ed Leafe wrote:
> Is there any way to "fake" the value of __name__? I can change it in
> daborun, but as soon as it imports the script, python sets it to the
> name of the script.

I don't think so. What you could do is just assume that if daborun is
being run with that script as a parameter, that we want to execute it if
it has a main() function. Something like:

import test
if hasattr(test, "main"):
test.main()

Otherwise, if no main function, nothing gets automatically executed
above and beyond what gets executed upon import (ie if there was no 'if
__name__="__main__"' branch).

--
Paul McNett - http://paulmcnett.com
vcard: http://paulmcnett.com/pm.vcf

 
©2004 Paul McNett
<-- Prior Message New Search Next Message -->