Re: print object attributes recursively

2009-09-30 Thread TerryP
On Sep 30, 1:49 pm, Piet van Oostrum wrote: > I don't know what print_r does, but in your example above > > print [x.L for x in t.M] would work. > > Probably you would split this into two methods in X and Y. > -- > Piet van Oostrum > WWW:http://pietvanoostrum.com/ > PGP key: [8DAE142BE17999C4] P

Re: print object attributes recursively

2009-09-30 Thread Piet van Oostrum
> "lallous" (l) wrote: >l> Hello >l> Suppose I have this code: >l> class X: >l>def __init__(self, n): >l>self.L = [x for x in xrange(0, n+1)] >l> class Y: >l>def __init__(self, n): >l>self.M = [X(x) for x in xrange(0, n)] >l> t = Y(5) >l> How can I easily print "t

print object attributes recursively

2009-09-29 Thread lallous
Hello Suppose I have this code: class X: def __init__(self, n): self.L = [x for x in xrange(0, n+1)] class Y: def __init__(self, n): self.M = [X(x) for x in xrange(0, n)] t = Y(5) How can I easily print "t" and all its nested attributes? (Something like PHP's print_r())