I'm writing a (very simple) command line window for use within my Tkinter GUI menu driven program (Aside: I want to provide a Matlab like command line capability within an otherwise menu driven program ... but where the script language is Python). The guts of executing the command are (where commandtext is a text variable captured from my command line window)
try: exec(commandtext) except: print 'failed to execute command' # we'll do something more sophisticated in due course The question is if commandtext contains invalid python I thought exec raised an exception that I could capture. I seem unable to get this to throw an exception no matter what is in commandtext. I assume I'm missing something simple here. Alternatively should I open a process with popen ... I want to be able to modify variables in the existing scope and the way I read popen I can't do that. ==================================================================== Prof Garry Willgoose, Australian Professorial Fellow in Environmental Engineering, Director, Centre for Climate Impact Management (C2IM), School of Engineering, The University of Newcastle, Callaghan, 2308 Australia. Centre webpage: www.c2im.org.au Phone: (International) +61 2 4921 6050 (Tues-Fri AM); +61 2 6545 9574 (Fri PM-Mon) FAX: (International) +61 2 4921 6991 (Uni); +61 2 6545 9574 (personal and Telluric) Env. Engg. Secretary: (International) +61 2 4921 6042 email: [EMAIL PROTECTED]; [EMAIL PROTECTED] email-for-life: [EMAIL PROTECTED] personal webpage: www.telluricresearch.com/garry ==================================================================== "Do not go where the path may lead, go instead where there is no path and leave a trail" Ralph Waldo Emerson ==================================================================== _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor