src/reportlab/lib/abag.py
changeset 3125 371c68e6a3c9
parent 3029 eded59f94021
child 3290 6e5e33a15a3d
equal deleted inserted replaced
3124:0ec012e69bc6 3125:371c68e6a3c9
    22         n = ABag(**self.__dict__)
    22         n = ABag(**self.__dict__)
    23         if attr: n.__dict__.update(attr)
    23         if attr: n.__dict__.update(attr)
    24         return n
    24         return n
    25 
    25 
    26     def __repr__(self):
    26     def __repr__(self):
    27         import string
    27         D = self.__dict__
    28         n = self.__class__.__name__
    28         K = D.keys()
    29         L = [n+"("]
    29         K.sort()
    30         keys = self.__dict__.keys()
    30         return '%s(%s)' % (self.__class__.__name__,', '.join(['%s=%r' % (k,D[k]) for k in K]))
    31         for k in keys:
       
    32             v = getattr(self, k)
       
    33             rk = repr(k)
       
    34             rv = repr(v)
       
    35             rk = "  "+string.replace(rk, "\n", "\n  ")
       
    36             rv = "    "+string.replace(rv, "\n", "\n    ")
       
    37             L.append(rk)
       
    38             L.append(rv)
       
    39         L.append(") #"+n)
       
    40         return string.join(L, "\n")
       
    41 
    31 
    42 if __name__=="__main__":
    32 if __name__=="__main__":
    43     AB = ABag(a=1, c="hello")
    33     AB = ABag(a=1, c="hello")
    44     CD = AB.clone()
    34     CD = AB.clone()
    45     print AB
    35     print AB