[Tutor] Exec function problem

Currall, Andrew andrew.currall at aecom.com
Wed Sep 1 17:22:05 CEST 2010

Using Python 2.5. 
DemandModel.py is a valid, working python script. If I create another
script file, then:


works fine. However, the apparently similar:

def runfile():

doesn't, for no apparent reason: I get 

  File "DemandModel.py", line 12, in DemandModel
NameError: global name 'ReadDmData' is not defined

Any ideas why? 

Use of 

CodeFile=open('DemandModel.py', 'r')

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.currall at aecom.com
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100901/16c9ed10/attachment-0001.html>

More information about the Tutor mailing list