GuidoS
GuidoS

Reputation: 707

traceback.print_exc() python question

I am using the following line of code in IDLE to print out my traceback in an eception:

traceback.print_exc()

For some reason I get the red text error message, but then it is followed by a blue text of "None".

Not sure what that None is about, any ideas?

Upvotes: 0

Views: 4776

Answers (2)

Alexander Lebedev
Alexander Lebedev

Reputation: 6044

print_exc() prints formatted exception to stderr. If you need string value, call format_exc()

Upvotes: 7

Ned Batchelder
Ned Batchelder

Reputation: 375814

print_exc() doesn't return anything, which in Python is actually returning None. Looks like IDLE is showing you the None it returned.

Upvotes: 6

Related Questions