Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- raise Exception("Hello world")
- Traceback (most recent call last):
- File "<ipython-input-24-dd3f3f45afbe>", line 1, in <module>
- raise Exception("Hello world")
- Exception: Hello world
- str(foo)
- Out[27]: 'Hello world'
- repr(foo)
- Out[28]: "Exception('Hello world',)"
- "{}".format(foo)
- Out[29]: 'Hello world'
- "{}: {}".format(type(foo), foo)
- Out[30]: "<type 'exceptions.Exception'>: Hello world"
- print('{}: {}'.format(type(exc).__name__, exc))
- #test.py
- import traceback
- try :
- raise TypeError("Wrong Type baby!")
- except Exception, e:
- print( "EXCEPTION FORMAT PRINT:n{}".format( e ) )
- print( "EXCEPTION TRACE PRINT:n{}".format( traceback.format_exc(e) ) )
- EXCEPTION FORMAT PRINT:
- Wrong Type baby!
- EXCEPTION TRACE PRINT:
- Traceback (most recent call last):
- File "/Users/me/test.py", line 4, in <module>
- raise TypeError("Wrong Type baby!")
- TypeError: Wrong Type baby!
Add Comment
Please, Sign In to add comment