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
Veek M
veek at dont-use-this.com
Tue Nov 19 09:08:52 EST 2019
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