Private attribute
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon Aug 25 17:30:13 EDT 2008
On Mon, 25 Aug 2008 21:44:49 +0100, Ken Starks wrote:
>>> ####################
>>>
>>> def __getattr__(self,attrname):
>>> if attrname == 'gridsize':
>>> return 0.8
>>>
>>> def __setattr__(self,attrname,value):
>>> if attrname == 'gridsize':
>>> pass
>>> else:
>>> self.__dict__[attrname]=value
>> […]
>
> I admit I haven't used properties, and had to look them up. Pretty cool
> indeed ! But an extra unnecessary level of complexity for my needs
> here, I feel.
Compare this with your approach above and point out the extra complexity
please:
@property
def gridsize(self):
return 0.8
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list