What is the idiomatic python way to hide traceback errors unless a verbose or debug flag is set?
Example code:
their_md5 = 'c38f03d2b7160f891fc36ec776ca4685'
my_md5 = 'c64e53bbb108a1c65e31eb4d1bb8e3b7'
if their_md5 != my_md5:
raise ValueError('md5 sum does not match!')
Existing output now, but only desired when called with foo.py --debug
:
Traceback (most recent call last):
File "b:\code\apt\apt.py", line 1647, in <module>
__main__.__dict__[command] (packages)
File "b:\code\apt\apt.py", line 399, in md5
raise ValueError('md5 sum does not match!')
ValueError: md5 sum does not match!
Desired normal output:
ValueError: md5 sum does not match!
Here's a test script: https://gist.github.com/maphew/e3a75c147cca98019cd8
print traceback
just shows object name anddir(traceback)
doesn't show anything I know what to do with. Here's what I have: gist.github.com/maphew/e3a75c147cca98019cd8 – Dak