import os

def include(filename):
    if os.path.exists(filename):
        exec(compile(open(filename).read(), filename, 'exec'))
include('myfile.py')
How to include external Python code to use in other files?