Re: __slots__ and class attributes

2005-11-04 Thread Ewald R. de Wit
Steven Bethard wrote: > But why do you want a class level attribute with the same name as an > instance level attribute? I would have written your class as: > > class A(object): > __slots__ = ['value'] > def __init__(self, value=1): > self.value = value > > where the default va

Re: __slots__ and class attributes

2005-11-03 Thread Steven Bethard
Ewald R. de Wit wrote: > I'm running into a something unexpected for a new-style class > that has both a class attribute and __slots__ defined. If the > name of the class attribute also exists in __slots__, Python > throws an AttributeError. Is this by design (if so, why)? > > class A( object ):

__slots__ and class attributes

2005-11-03 Thread Ewald R. de Wit
I'm running into a something unexpected for a new-style class that has both a class attribute and __slots__ defined. If the name of the class attribute also exists in __slots__, Python throws an AttributeError. Is this by design (if so, why)? class A( object ): __slots__ = ( 'value', )