Re-inspection of values in a Traceback
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping
--
Chapters
00:00 Re-Inspection Of Values In A Traceback
01:14 Accepted Answer Score 5
01:32 Thank you
--
Full question
https://stackoverflow.com/questions/5182...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #exception #evaluate
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping
--
Chapters
00:00 Re-Inspection Of Values In A Traceback
01:14 Accepted Answer Score 5
01:32 Thank you
--
Full question
https://stackoverflow.com/questions/5182...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #exception #evaluate
#avk47
ACCEPTED ANSWER
Score 5
You can use inspect module :
try:
foo()
except AssertionError, e:
import inspect
previous_trace = inspect.trace()[1]
frame = previous_trace[0]
print 'value of a, b:', inspect.getargvalues(frame).locals
See http://docs.python.org/library/inspect.html#inspect.getargvalues