What's happen, if you use global in test2.py? x is local to test2.py. Another possibility is to use __main__ module. But these is now depreciated. > ############## > #### test2.py #### global x > x = 'spam' > > #### test.py #### > def doit(): > execfile( 'test2.py' ) # x = 'spam' global x > print x > > doit() > ##############