Defining inheritance in C extensions

Michael Hudson mwh at python.net
Fri Nov 9 06:45:51 EST 2001


Timo Savola <timo.savola at iki.fi> writes:

> Hello. I'm new to this list, and relatively new to Python (played around
> with it every now and then, and used it as a calculator :).

Greetings.

> Now I'm doing an extension module, or rather a system that I want to
> control via Python. I have a C++ class hierarchy that I want to be
> accessible from Python. 

Have you looked at Boost::Python?  I haven't, but I've heard it's good
for this sort of thing.

> I can't figure out how to make a type object a subclass of another
> type object, so that I can do type checking in the Python wrappers
> of my methods.

This has only *very recently* become possible, so if you wan't to know
how, it's "use the source, Luke."

> I've been browsing the Extending and Embedding section of the Python
> documentation (version 2.2). Is it just me, or has the Defining New
> Types section fallen short? It doesn't say anything about /*
> Attribute descriptor and subclassing stuff */...

See above; hopefully documentation will get written before Python 2.2
is out.  Trouble is, there are very few people competent to write such
documentation, and half of them are on paternity leave.

> Is there a more extensive reference to extending Python,

Don't think so.  I wanted to write one once, but it's hard and I ran
out of time/steam.

> or maybe some comprehensive example code on the subject?

Much of the Python source itself is written in the same style as you
write extensions in.  Particularly the stuff in Modules/ -- that's in
precisely the same style, as those files *are* extending Python...

> Thanks in advance. :)

Cheers,
M.

-- 
  There's a difference between random people with stripy jumpers, 
  and a respected scientist with a reputation.
                                            -- Steve Kitson, ucam.chat



More information about the Python-list mailing list