Simon Brunning wrote: > On 14 Dec 2006 05:23:33 -0800, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > > Hi all, > > >From the google search, it seems its not possible to do the following. > > > > >>> class Test1(object): > > ... __slots__ = ['a'] > > ... > > >>> class Test2(object): > > ... __slots__ = ['b'] > > ... > > >>> class Test3(Test1,Test2): > > ... __slots__ = ['c'] > > ... > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > TypeError: Error when calling the metaclass bases > > multiple bases have instance lay-out conflict > > > > I just want to make sure that I am using only the attributes a,b and c > > from the instances of Test3 . Is there any other hack that could be > > done. > > Difficulty with subclassing is the price you pay for abusing slots. > Slots are intended as a performance tweak only, to minimise the memory > footprint of classes of which you are going to have a great number of > instances. > > In short - don't do that. OK. But is there any other way to do what __slots__ does as a 'side effect' i.e. forcing me to think about the list of attributes my class is going to have upfront and raising error whenever I violate it. IMHO this is a very good thing to have even if one does not care about memory.
-- Suresh > > -- > Cheers, > Simon B > [EMAIL PROTECTED] > http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list