Using Python 2.5. DemandModel.py is a valid, working python script. If I create another script file, then:
execfile('DemandModel.py') works fine. However, the apparently similar: def runfile(): execfile('DemandModel.py') runfile() doesn't, for no apparent reason: I get File "DemandModel.py", line 12, in DemandModel Parameters=ReadDmData(segname) NameError: global name 'ReadDmData' is not defined Any ideas why? Use of CodeFile=open('DemandModel.py', 'r') exec(CodeFile) instead of execfile, doesn't make any difference either way, nor does it make any difference if I read the file using read() and then execute the string- in all cases the top-level command works; placed in a function it doesn't. Regards and thanks, Andrew Currall MPhys Senior Consultant, Transportation D +44 (0)1727 535612 andrew.curr...@aecom.com AECOM AECOM House 63-77 Victoria Street St Albans, Herts AL1 3ER T +44 (0)1727 535000 F +44 (0)1727 535099 www.aecom.com <http://www.aecom.com/> This email is confidential and is for the intended recipient only. If you are not the intended recipient, please contact the author and you must not disclose or use the contents in any way. The author bears responsibility for any legal action or disputes arising from views or professional advice expressed which do not relate to the business of AECOM Ltd. AECOM Limited Registered in England No: 1846493 Registered Office: AECOM House, 63-77 Victoria Street, St Albans, Herts, AL1 3ER Please consider the environment before printing this e-mail
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor