oo problem

Nils Oliver Kröger NO_Kroeger at gmx.de
Sun Dec 10 05:42:58 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

many class libraries use a parent attribute for this purpose:

class Rectangle (object):
	__init__(self, parent):
		#Use the parent as "private": nobody except your own 				#class should
mess around with it ...
		self._parent = parent

The parent of course needs to be an existing Paper instance.

You might check whether the given value for parent is indeed a Paper
instance in your Rectangle's __init__, otherwise you might get strange
AttributeError exceptions when using the parent later.

Hope that helps!

Nils


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFe+SyRQeuB6ws8wERAuTOAKCPKe8m9BNP7Vf/aFpJSWTfOkF8pQCgvkxG
+xmcU+UB7fT0fi8/Jz+o15E=
=pW+u
-----END PGP SIGNATURE-----



More information about the Python-list mailing list