>>>>> "lallous" <lall...@lgwm.org> (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" and all its nested attributes? (Something like
>l> PHP's print_r())

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 <p...@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to