Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-11-13 12:50:03


Ivan,

this appears to be a built-in limitation of Python. It is complaining
because A's __init__ function is "special", and requires a true Python
instance. Objects of type B are not true instances.

The best workaround I can think of is to derive A from an extension class.
You could just wrap a boring empty struct.

:(

-Dave

----- Original Message -----
From: "Ivan A. Vigasin" <vig_at_[hidden]>

> Hello, All
>
> I have problem with mixing extension classes with python classes.
>
> $ python tmp.py
> Traceback (most recent call last):
> File "tmp.py", line 12, in ?
> b=B()
> File "tmp.py", line 10, in __init__
> A.__init__(self)
> TypeError: unbound method __init__() must be called with instance as
first argument
>
> Where tmp.py is:
>
> class A:
> def __init__(self):
> pass
>
> from extmodule import ExtClass
>
> class B(A,ExtClass):
> def __init__(self):
> A.__init__(self)
> ExtClass.__init__(self)
>
> b=B()
>
> In C++:
> test_boost.cc:
> ...
> python::class_builder<ExtClass> connect_class(this_module, "ExtClass" );
> connect_class.def( python::constructor<>() );
> ...
>
> All OK when using single inheritance or multiple with both extension
classes.
>
> Regards, Ivan <vig_at_[hidden]>
> ICQ: 22181170
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk