__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', )

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: directory bug on linux; workaround?

2005-01-17 Thread Ewald R. de Wit
Russell E. Owen wrote: > It seems that the path was to a "fat" file partition and included a > directory name that was all uppercase. The directory was created, but > using lowercase. I'm not yet sure the version of python. > > The workaround for now is to not use fat file partitions. But I was

Re: cyclic data structures

2006-02-14 Thread Ewald R. de Wit
John Salerno wrote: > I'm having some slight trouble understanding exactly why this creates an > infinite loop: > > L = [1, 2] > L.append(L) I tried this with Python 2.3.5 and it handles this tailbiter in a very pleasantly surprising way: >>> l = [ 0, 1 ] >>> l.append( l ) >>> l [0, 1, [...]] >>