Issue
I have a traceback in an IPython notebook that I'm debugging with the %debug
magic. I'd like to assign one of the objects in the traceback frame to a variable in the IPython global namespace, so that I can mess with it outside the ipdb
prompt (which is rather clunky). What's the easiest way to do this?
I solved this for now by pickling the object in ipdb and unpickling it from the global namespace, but I'm sure there's a better way.
Solution
One way would be to assign the value to a module-member (something like a global var in module's scope), which persists after you quit the pdb
session, since the module is already in sys.modules
, and stays there.
1% os.path.exists(3254)
...
TypeError: coercing to Unicode: need string or buffer, int found
2% %debug
...
ipdb> os.MYVAR = 234
ipdb> q
3% os.MYVAR
3= 234
Answered By - shx2
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.