circular import snafu

Darrell Gallion darrell at dorb.com
Thu Aug 10 21:04:06 EDT 2000


Here's some fun with imports.
When things get really sticky I add a startup function.

--Darrell

open("f1.py",'w').write("""
import f2

x=5
f2.startUp()
f2.run()
""")

open("f2.py",'w').write("""
import sys

def startUp():
    import f1
    sys.modules[__name__].__dict__['x']=f1.x

def run():
    print 'Run:', x
""")

import f1

# Also try running just f1.py






More information about the Python-list mailing list