print object attributes recursively

lallous lallous at lgwm.org
Tue Sep 29 17:30:14 CEST 2009


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())

Thanks,
Elias 




More information about the Python-list mailing list