[Tutor] Puzzled by execfile()
André Roberge
andre.roberge at ns.sympatico.ca
Thu Oct 21 02:36:44 CEST 2004
Dear Tutors,
I have the following two Python files
===Script1.py ===
def printfoo():
print "foo"
execfile("Script2.py")
===Script2.py===
from Script1 import *
print "starting"
printfoo()
print "done"
==============
When I run Script1 for the FIRST time (from within IDLE or PythonWin), I get
starting
foo
done
starting
foo
done
When I run it again, I only get
starting
foo
done
each time that I run it. I don't understand why Script2 seems to be run
twice the first time around
André Roberge
More information about the Tutor
mailing list