Traceback2 example for maya

Hi all.

I have been reading Rob’s practical Maya programming with python. In it he mentions briefly using traceback2 as a way of inspecting local variables in a traceback. I downloaded the module but I wasn’t able to use it meaningfully, does anyone have any experience in using it in conjunction with maya, and if so could you provide a simple example showing its usage?

thanks!

Shane

from the docs it looks like you’d use it just like the built in traceback module:


import traceback2
try:
     fred = 1
     barney = 0
     print fred / barney
except:
     traceback2.print_exc(show_locals=True)

DISCLAIMER: that’s based on a cursory read of the the docs, not usage

Ha yeah that worked fine in maya (had to make a slight modification and remove the calls to the compat module). Thanks for taking the time to answer such a simple question!