Multi Heritage with slots
Eric Brunel
see.signature at no.spam
Wed Sep 5 06:42:28 EDT 2007
On Wed, 05 Sep 2007 11:01:56 +0200, Alexandre Badez
<alexandre.badez at gmail.com> wrote:
> Hye,
>
> I'm developing a little app, and I want to make multi heritage.
> My problem is that my both parent do have __slots__ define.
>
> So I've got something like:
>
> class foo(object):
> __slots__ = ['a', 'b']
> pass
>
> class foo2(object):
> __slots__ = ['c', 'd']
> pass
>
> class crash(foo, foo2):
> pass
>
> If you write only that in a sample file or in python console (as I
> did), python refuse to load the module and report something like:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: Error when calling the metaclass bases
> multiple bases have instance lay-out conflict
>
> Do you know why it append? And how could I make this work?
See http://mail.python.org/pipermail/python-list/2006-December/418768.html
Basically, the general advice you're likely to get here is: don't use
__slots__, or at least don't use __slots__ with inheritance.
BTW, what are you trying to do? Is it really a memory footprint
optimization, which is the intended use case for __slots__, or are you
just doing Java in Python?
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
More information about the Python-list
mailing list