try except inside exec

Emile van Sebille emile at fenx.com
Fri May 29 12:47:54 EDT 2009


On 5/29/2009 8:55 AM Michele Petrazzo said...
> Aaron Brady wrote:
<snip>
>> Then the formatted exception will be available in 'err'.  Do you want
>> the exception-handling to be part of the function you are entering
>> into 'env'?
> 
> My goal is to execute a function received from a third-part, so I cannot 
> modify as you made in your first piece of code.
> I want a "clean" exception with the real line code/tb so I can show a 
> "real" error message. This means that the try/execpt has to include the 
> passed function and catch every possible exception.
> 
> Do you have any ideas on how can I figure this out?

Write the string out to a .py file and import it?

Emile




More information about the Python-list mailing list