reportlab/lib/abag.py
changeset 548 223699ff68fc
parent 517 dffd258916bc
child 561 58942687b2e1
--- a/reportlab/lib/abag.py	Fri Dec 15 11:49:45 2000 +0000
+++ b/reportlab/lib/abag.py	Fri Dec 15 14:24:09 2000 +0000
@@ -1,7 +1,7 @@
 #copyright ReportLab Inc. 2000
 #see license.txt for license details
 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/lib/abag.py?cvsroot=reportlab
-#$Header: /tmp/reportlab/reportlab/lib/abag.py,v 1.1 2000/11/29 16:16:33 rgbecker Exp $
+#$Header: /tmp/reportlab/reportlab/lib/abag.py,v 1.2 2000/12/15 14:24:09 aaron_watters Exp $
 class ABag:
 	"""
 	A trivial BAG class for holding attributes
@@ -14,3 +14,25 @@
 		n = apply(ABag,(),self.__dict__)
 		if attr != {}: apply(ABag.__init__,(n,),attr)
 		return n
+
+	def __repr__(self):
+		import string
+		n = self.__class__.__name__
+		L = [n+"("]
+		keys = self.__dict__.keys()
+		for k in keys:
+			v = getattr(self, k)
+			rk = repr(k)
+			rv = repr(v)
+			rk = "  "+string.replace(rk, "\n", "\n  ")
+			rv = "    "+string.replace(rv, "\n", "\n    ")
+			L.append(rk)
+			L.append(rv)
+		L.append(") #"+n)
+		return string.join(L, "\n")
+		
+if __name__=="__main__":
+	AB = ABag(a=1, c="hello")
+	CD = AB.clone()
+	print AB
+	print CD
\ No newline at end of file