Python Inheritance - A C example (without third party libraries)
jkraska1 at san.rr.com
Sat May 12 07:07:04 EDT 2001
>Can someone give me a source code example of how to derive a python class
>(written in C) ....
There are no classes in C. There is no "derivation" (sic) in C.
>from another python class (also written in C) such that...
There are no classes in C.
>a. Derive further classes from it (in python)
This is normal object behavior in python. See xxobject.c in the source release
for more details. I also recommend _Essential Python Reference_, which has
one of the better-written sections on Extending and Embedding that I've ever
seen. Native classes in Python are not characterized by any "inheritance"
in the native C language (there is no inheritance in C)); rather, objects are
differentiated by their signature, the functions they offer, and the mapping of
the type name to a known glue structure. If you wish to write an extension
object which "inherits" (sic) from another native-C Python object, you're
going to have to do this the hard way or use a code-generator.
>b. Determine if a derived class is a subclass of a particular base class (in
There are no classes in C. There are no derived, sub-, parrent-, or base-
classes in C.
>I know there are resources such as CXX, SCXX and the boost library but none
>of these seem to make it clear and the python doc's aren't up to scratch in
_Essential Python Reference_ is good.
More information about the Python-list