how to "source" a file?

Mark Harrison mh at dreadnok.pixar.com
Thu Mar 18 02:01:38 CET 2004


Specifically, I'm confused why

def dfpostadd(name):
    """per-unit postprocessing step"""
    sys.path.append('/my/config/path')
    import dfacommon
    dfacommon.addm(name)

works, but this doesn't:

sys.path.append('/my/config/path')
import dfacommon
def dfpostadd(name):
    """per-unit postprocessing step"""
    dfacommon.addm(name)

which gives me:

msg=global name 'dfacommon' is not defined trace=['  File "<string>",
line 341, in doadd\n', '  File "/usr/anim/config/ndfd/mark.cfg",
line 55, in dfpostadd\n    dfacommon.addm(name)\n'] 


Many TIA,
Mark



More information about the Python-list mailing list