subtyping a builtin type in a C extension

S

shawn

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?
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

shawn said:
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..../Modules/xxsubtype.c?rev=2.15.2.1&view=markup

-- Gerhard
 
S

shawn

Thank you. I should have looked for this sort of example. That was
exactly what I needed.

I don't ask for help here very often, but when I have, I have ALWAYS
gotten faster results than with any commercial support option I have
used. We have a good developer community :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top