[IPython-user] get stack from current pdb instance

Jon Olav Vik jonovik@gmail....
Wed Dec 2 20:44:34 CST 2009


Nathan Huesken <ipython <at> lonely-star.org> writes:

> Is it possible to get the current call-stack from the current pdb
> instance?
> 
> I noticed:
> __IP.InteractiveTB.pdb.get_stack()
> 
> It takes 2 arguments, I found no documentation and have no idea what to
> pass ...

(After writing the post below, it struck me that your question might be better 
asked at 
http://news.gmane.org/gmane.comp.python.ipython.devel
because you seem to be delving quite deeply into IPython internals.)

The source code isn't very long. If you know what you're doing (I don't), you 
can probably figure it out yourself. Specifically,

>>> ??__IP.InteractiveTB.pdb.get_stack()
    def get_stack(self, f, t):
        stack = []
        if t and t.tb_frame is f:
...

Just from the sound of it, I'd guess t is a traceback 
http://docs.python.org/library/traceback.html
and f is a (stack) frame. Searching the plain Python docs for tb_frame:
http://www.google.com/search?
q=tb_frame&domains=docs.python.org&sitesearch=docs.python.org

http://docs.python.org/library/inspect.html
traceback
	tb_frame	frame object at this level	 
 	tb_lasti	index of last attempted instruction in bytecode	 
 	tb_lineno	current line number in Python source code	 
 	tb_next	next inner traceback object (called by this level)

Hope this helps,
Jon Olav




More information about the IPython-user mailing list