Re: block dynamic attribute creation

2009-02-19 Thread Alan G Isaac
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

Re: block dynamic attribute creation

2009-02-19 Thread Gabriel Genellina
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

Re: block dynamic attribute creation

2009-02-19 Thread Alan G Isaac
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

Re: block dynamic attribute creation (was: get descriptor from instance)

2009-02-19 Thread Gabriel Genellina
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

Re: block dynamic attribute creation

2009-02-19 Thread Bruno Desthuilliers
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__

Re: block dynamic attribute creation (was: get descriptor from instance)

2009-02-18 Thread Alan G Isaac
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