Is there a piece of code ('inspect') that displays all/most of the attributes/methods in a frame, traceback, generator object in a readable fashion

Antoon Pardon antoon.pardon at vub.be
Tue Nov 19 09:37:06 EST 2019


Maybe you should have a look at:
http://code.activestate.com/recipes/52215-get-more-information-from-tracebacks/

On 19/11/19 15:08, Veek M wrote:
> Basically I want to call a method and pretty print the object contents 
> for some code I'm playing with.
>
> Instead of manually writing all this crud. Something like a python object 
> explorer.
>
>
>
> def foo(a, x = 10):
>     2 + 2
>
> def bar():
>     pass
>
> class A:
>     pass
>
> class Foo(A, object):
>     def __init__(self):
>         2 + 2
>
>     def mymethod(self):
>         2 + 2
>
> f = Foo()
>
> import inspect
> f = inspect.currentframe()
> print f.f_locals, '\n\n', f.f_globals
>
> print f.f_lasti, f.f_back, f.f_code, f.f_lineno
>
> print f.f_trace
> #print f.f_builtins
>
> print f.f_code.co_name
> print f.f_code.co_filename
> print f.f_code.co_argcount
> print f.f_code.co_varnames
> print f.f_code.co_nlocals



More information about the Python-list mailing list