Re: Step-by-step exec

2008-11-07 Thread M.-A. Lemburg
On 2008-11-07 11:48, [EMAIL PROTECTED] wrote: On Nov 7, 11:20 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: What I am trying to do is to execute it step-by-step, so that I can capture the exception if one line (or multi-line statement) fails, print a warning about the

Re: Step-by-step exec

2008-11-07 Thread Steven D'Aprano
On Thu, 06 Nov 2008 03:27:53 -0800, gregory.lielens wrote: Hi, I am using a small python file as an input file (defining constants, parameters, input data, ...) for a python application. The input file is simply read by an exec statement in a specific dictionary, and then the application

Re: Step-by-step exec

2008-11-07 Thread gregory . lielens
On Nov 6, 9:53 pm, Aaron Brady [EMAIL PROTECTED] wrote: Check out the InteractiveConsole and InteractiveInterpreter classes. Derive a subclass and override the 'push' method.  It's not documented so you'll have to examine the source to find out exactly when and what to override. Thanks, this

Re: Step-by-step exec

2008-11-07 Thread gregory . lielens
On Nov 7, 11:20 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: What I am trying to do is to execute it step-by-step, so that I can capture the exception if one line (or multi-line statement) fails, print a warning about the failure, and continue the execution fo the

Step-by-step exec

2008-11-06 Thread gregory . lielens
statements or loops. Is there a better way for a step-by-step exec? Syntax errors in the input script are not really a problem (as it is generated elsewhere, it is not directly edited by users), although it would be nice to catch. The biggest problem are runtime errors (attribute error, value error

Re: Step-by-step exec

2008-11-06 Thread [EMAIL PROTECTED]
need not be a full python script too, you could just have token delimited blocks of python code which are read in 1 block at a time and then exec(). -srp Is there a better way for a step-by-step exec? Syntax errors in the input script are not really a problem (as it is generated elsewhere

Re: Step-by-step exec

2008-11-06 Thread gregory . lielens
, you could read each block in one at a time and do a compile() and exec(). Your input file need not be a full python script too, you could just have token delimited blocks of python code which are read in 1 block at a time and then exec(). -srp Is there a better way for a step-by-step exec

Re: Step-by-step exec

2008-11-06 Thread Aaron Brady
and then exec(). -srp Is there a better way for a step-by-step exec? Syntax errors in the input script are not really a problem (as it is generated elsewhere, it is not directly edited by users), although it would be nice to catch. The biggest problem are runtime errors (attribute