Why I need to declare import as global in function

didier.doussaud at gmail.com didier.doussaud at gmail.com
Wed Nov 30 03:52:10 EST 2005


lot's of solutions proposed in the discussion works fine :

file run.py :
----------------
def run_ut( test ) :
    # to have the problem the execfile MUST be in a function
    # execfile( test ) # ERROR
    execfile( test, globals() ) # OK
    exec "import ut_00" # OK
    exec file(test).read() # OK
run_ut( "ut_00.py" )

Thanks a lor




More information about the Python-list mailing list