subclassing pyrex extension types in python

Nitin nmadnani at
Fri Jan 19 04:53:58 CET 2007

Hi All

I am trying to subclass an extension type in Python and add attributes
to the new class but I keep getting errors. I read the "Extension
Types" document on the Pyrex website but I couldn't get an answer from

Here's the Spam extension type from Pyrex website:

cdef class Spam:

  cdef int amount

  def __new__(self):
    self.amount = 0

  def get_amount(self):
    return self.amount

Once compiled, here's how I am using this:

import spam

class mySpam(spam.Spam):
    def __init__(self, name1=None, name2=None):
        self.name1 = name1
        self.name2 = name2

When I run this Python code, I get an error "TypeError: 'name2' is an
invalid keyword argument for this function"

Is there something I need to know about Pyrex extension types and
keyword arguments ? I tried to google for this but couldn't come up
with anything.

Thanks !

More information about the Python-list mailing list