setting a property via self.__dict__

Frank von Delft fvondelft at syrrx.com
Wed Oct 30 15:51:47 EST 2002


Duncan Booth <duncan at rcp.co.uk> wrote in message news:<Xns92B75C6BDF4Eduncanrcpcouk at rcp.co.uk>...

> The property is an entry in the class's dictionary, not in the instance.


Um...  after some mulling:  so what is the advantage of having the
property in the class dictionary?  Because I realised it's quite happy
in the instance dictionary, like such:

>>> class A(object):
	def __init__(self,**kwargs):
		self.a = property(self._getA,self._setA)
		self.__dict__.update(**kwargs)
	def _getA(self): 
		return self._a
	def _setA(self,a):
		self._a = a

Really I should ask:  why do all the examples show it defined in the
class dictionary?

Cheers
Phraenquex



More information about the Python-list mailing list