Hello,

I am using Cython 0.14.1 with Python 2.7.1 on OSX 10.6.7

The following code:
---
cdef class Test:
        @staticmethod
        def func():
                print "Static method"
---
gives error when being cythoned: "Method func has wrong number of
arguments (0 declared, 1 or more expected)"

And if one adds some parameters to this method (like "def func(a,
b):"), cython crashes with exception:
---
... long stack trace ...
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Cython-0.14-py2.7-macosx-10.6-intel.egg/Cython/Compiler/TypeSlots.py",
line 100, in fixed_arg_type
    return self.format_map[self.fixed_arg_format[i]]
KeyError: 'T'
---

So, is there a way to create static methods in cdef classes? This
workaround seems to work, but it is a bit ugly:
---
def func(a, b):
        print "Static method"

cdef class Test:
        func = func
---

Best regards,
Bogdan
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to