object data member dumper?
tom arnall
kloro2006 at gmail.com
Tue Nov 7 17:32:28 EST 2006
Bruno Desthuilliers wrote:
> tom arnall a écrit :
>> does anyone know of a utility to do a recursive dump of object data
>> members?
>>
>
> What are "object data members" ? (hint: in Python, everything is an
> object - even functions and methods).
>
> What is your real use case ?
something like:
class A:
def __init__(self, p1):
self.p1 = p1
class B:
def __init__(self,p1, p2):
self.a = A(p1)
self.p2 = p2
self.v1 = '3'
class C:
def __init__(self):
self.b = B(3,4)
self.p3 = 5
class D:
def __init__(self):
self.v2=2
self.o1 = C()
self.o2 = B(11,12)
d = D()
objectDataDumper(d)
would produce something like:
object of class D with:
o1(C)->b(B)->a(A)->p1=3
o1(C)->b(B)->p2=4
o1(C)->b(B)->v1=3
o1(C)->p3=5
o2(B)->a(A)->p1=11
o2(B)->p2=12
o2(B)->v1=3
v2=2
tom arnall
north spit, ca
usa
--
Posted via a free Usenet account from http://www.teranews.com
More information about the Python-list
mailing list