If I have that code:
try:
some_method()
except Exception, e:
How can I get this Exception value (string representation I mean)?
Even though I realise this is an old question, I'd like to suggest using the traceback module to handle output of the exceptions.
Use traceback.print_exc()
to print the current exception to standard error, just like it would be printed if it remained uncaught, or traceback.format_exc()
to get the same output as a string. You can pass various arguments to either of those functions if you want to limit the output, or redirect the printing to a file-like object.