Faking out __name__ == __main__
Josiah Carlson
jcarlson at uci.edu
Mon Nov 1 01:58:49 EST 2004
bokr at oz.net (Bengt Richter) wrote:
>
> On Sun, 31 Oct 2004 17:05:59 -0500, Ed Leafe <ed at leafe.com> wrote:
> >>> def test():
> ... d = {'__name__': '__xxxx__'}
> ... execfile('tmain.py', d)
I believe it is technically more Pythonic to use __import__ rather than
execfile, if only because you have access to the module itself when you
are done.
- Josiah
More information about the Python-list
mailing list