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 following > > lines/statements. Of course, an error on one line can trigger errors in > > the following lines, but it does not matter in the application I have in > > mind, > > I'm curious what sort of application you have where it doesn't matter > that programmatic statements are invalid. Well, it is not that it does not matter, it is that I'd like to get as much as possible of the input file "executed". The application is roughly to save a graph, and retrieve it later. The graph is made of a set of python classes, derived from a GraphNode instance but each having particular sets of new attributes. The storage format should be human readable and editable (this is why a simple pickle or equivalent is not OK), store only part of the database, and automatically reflect the changes of the classes (new attributes in old classes, new classes, ...). The format I used was "simply" instructions that re-create the graph... It works, but could be robust accross changes (basically, an old database read with new version of the application should recreate as much nodes as possible, with new attributes intialized at default value). The node classes allows that, but during the parsing when attributes names or classes names have changed, some errors can happen, which will not only affect those nodes but stop execution. In many cases, even with those error, executing the rest of the commands will re-create an usefull graph, of course lacking some informations but much more usefull that the partial graph obtained when stopping at the first error... >So basically you want to create a Python interpreter you can stop and >start which runs inside Python. Is that right? Yep, and the InteractiveConsole works very nicely for doing that :-) -- http://mail.python.org/mailman/listinfo/python-list