On 2/19/2009 3:47 AM Bruno Desthuilliers apparently wrote:
if not hasattr(self, attr) and getattr(self, '_attrlock', False):
raise AttributeError(yadda yadda)
# NB: assume newstyle class
super(YourClass, self).__setattr__(attr, val)
Thanks.
Alan
PS Thanks also to all
En Thu, 19 Feb 2009 13:20:25 -0200, Alan G Isaac
escribió:
if hasattr(self, attr): #update val
self.__dict__[attr] = val
On 2/19/2009 3:54 AM Gabriel Genellina apparently wrote:
In particular, your code prevents using class attributes as a default
value for instance attrib
if hasattr(self, attr): #update val
self.__dict__[attr] = val
On 2/19/2009 3:54 AM Gabriel Genellina apparently wrote:
In particular, your code prevents using class attributes as a default
value for instance attributes
Doesn't the above allow that?
Thanks,
Alan
--
http://mai
En Thu, 19 Feb 2009 01:29:17 -0200, Alan G Isaac
escribió:
OK, that's good. I'd like to sometimes lock attribute creation on
instances of a class but still allow properties to function
correctly. Will something like below be satisfactory?
def __setattr__(self, attr, val):
"""If insta
Alan G Isaac a écrit :
On 2/18/2009 6:15 PM Gabriel Genellina apparently wrote:
type(a).x
OK, that's good. I'd like to sometimes lock attribute creation on
instances of a class but still allow properties to function
correctly. Will something like below be satisfactory?
>
def __setattr__
On 2/18/2009 6:15 PM Gabriel Genellina apparently wrote:
type(a).x
OK, that's good. I'd like to sometimes lock attribute creation on
instances of a class but still allow properties to function
correctly. Will something like below be satisfactory?
Thanks,
Alan
def __setattr__(self, attr, v