Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > subtyping a builtin type in a C extension

Reply
Thread Tools

subtyping a builtin type in a C extension

 
 
shawn
Guest
Posts: n/a
 
      10-17-2005
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?

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Gerhard_H=E4ring?=
Guest
Posts: n/a
 
      10-17-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.p....1&view=markup

-- Gerhard

 
Reply With Quote
 
 
 
 
shawn
Guest
Posts: n/a
 
      10-17-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtyping iterators Michael Le Barbier Grünewald C++ 5 05-14-2012 08:23 AM
subtle error slows code by 10x (builtin sum()) - replace builtin sumwithout using import? bdb112 Python 2 07-02-2011 03:13 AM
Subtyping a non-builtin type in C/C++ johan2sson@gmail.com Python 3 08-13-2006 07:23 PM
Subtyping issue valentin tihomirov VHDL 1 06-30-2005 01:42 PM
Private Inheritance is not subtyping Ragnar C++ 2 11-07-2003 04:34 PM



Advertisments