subtyping a builtin type in a C extension

Discussion in 'Python' started by shawn, Oct 17, 2005.

  1. shawn

    shawn Guest

    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?
    shawn, Oct 17, 2005
    #1
    1. Advertising

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

    -- Gerhard
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Oct 17, 2005
    #2
    1. Advertising

  3. shawn

    shawn Guest

    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 :)
    shawn, Oct 17, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. valentin tihomirov

    Subtyping issue

    valentin tihomirov, Jun 30, 2005, in forum: VHDL
    Replies:
    1
    Views:
    532
    Jonathan Bromley
    Jun 30, 2005
  2. Ragnar
    Replies:
    2
    Views:
    339
    Dan Cernat
    Nov 7, 2003
  3. Replies:
    3
    Views:
    366
  4. bdb112
    Replies:
    2
    Views:
    289
    Chris Torek
    Jul 2, 2011
  5. Michael Le Barbier Grünewald

    Subtyping iterators

    Michael Le Barbier Grünewald, May 9, 2012, in forum: C++
    Replies:
    5
    Views:
    394
Loading...

Share This Page