On Fri, 2004-12-24 at 20:07, Nitin Shukla wrote: > Hello, > > Can anyone tell why am I getting this error and how to work around this > problem. > > >>> class Klass(object): > ... __slots__ = ( 'x' ) > ... > >>> class Klass1(object): > ... __slots__ = ( 'y' ) > ... > >>> class Klass(Klass, Klass1): > ... __slots__ = ( 'z' ) > ... > Traceback (most recent call last): > File "<interactive input>", line 1, in ? > TypeError: multiple bases have instance lay-out conflict > > I need to define slots in these classes and also need to inherit them in > Derived class.
If I recall correctly, the standard advice in this situation is "don't use __slots__. If you think you need __slots__, still don't use __slots__." I've made use of __slots__ once myself for an optimisation when subclassing `str', but if you're not using it for a serious optimisation need it's probably best to steer clear. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list