I have a class with an attribute called 'gridsize' and I want
a derived class to force and keep it at 0.8 (representing 8mm).
Is this a correct, or the most pythonic approach?
############### #####
def __getattr__(sel f,attrname):
if attrname == 'gridsize':
return 0.8
def __setattr__(sel f,attrname,valu e):
if attrname == 'gridsize':
pass
else:
self.__dict__[attrname]=value
############### ######
Cheers,
Ken.
a derived class to force and keep it at 0.8 (representing 8mm).
Is this a correct, or the most pythonic approach?
############### #####
def __getattr__(sel f,attrname):
if attrname == 'gridsize':
return 0.8
def __setattr__(sel f,attrname,valu e):
if attrname == 'gridsize':
pass
else:
self.__dict__[attrname]=value
############### ######
Cheers,
Ken.
Comment