subtyping a builtin type in a C extension

Gerhard Häring gh at ghaering.de
Mon Oct 17 04:42:40 EDT 2005


shawn wrote:
> I am trying to make a subtype of a string. Initially it will have no
> new methods or attributes, the C equivalent of:
> 
> class myStr(str):
>     pass
> 
> I have experimented a bit, but am currently making a mess of it. Does
> anybody have an example they can point to of inheriting from a builtin,
> or a suggestion to point me in the right direction?

The Python source distribution contains an example module xxsubtype that 
shows how to subclass builtins:

http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/xxsubtype.c?rev=2.15.2.1&view=markup

-- Gerhard




More information about the Python-list mailing list