I don't know, but you can code an "instance explorer" exploiting the
__dict__ method:
import re
def show_data(instance):
myformat = lambda x: re.sub("[^\S ]", "", str(x))
element_dictionary = dict([(myformat(key), myformat(value)) for
(key, value) in instance.__dict__.items()])
# The __dict__ method holds pairs of attrib name:value
max_keylength = max([len(x) for x in element_dictionary.keys()]+[9])
max_valuelength = max([len(x) for x in element_dictionary.values()]+[5])
print("\nObject:", myformat(instance))
print("Attribute".ljust(max_keylength+2)+":"+"
Value".ljust(max_valuelength))
print("-"*(max_keylength+max_valuelength+3))
for key in sorted(element_dictionary.keys()):
print(key.ljust(max_keylength+1), ":",
str(element_dictionary[key]).ljust(max_valuelength))
class MyClass():
def __init__(self,a,b,c):
self.d = a
self.e = b
self.f = c
testinstance = MyClass(1,2,3)
show_data(testinstance)
'''
Try also:
class Test(object):
def __init__(self):
self.attribute = "This has value A"
self.bitipiribute = "B"
self.dribute = object()
self.c = "This is very, very, very, very, very long \n and has a newline"
x = Test()
show_data(x)
'''
--
You received this message because you are subscribed to the Google Groups
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.