Cython has moved to github.
cython-devel
view tests/run/cdef_methods_T462.pyx @ 2744:25af3c07d7c3
minor refactoring; fix handling first argument in classmethods; fix ticket #462: allow method(*args) in cdef classes
| author | Stefan Behnel <scoder@users.berlios.de> |
|---|---|
| date | Sat Dec 05 23:39:57 2009 +0100 (2 years ago) |
| parents | 6ab740905f96 |
| children |
line source
2 cimport cython
4 cdef class cclass:
5 def test_self(self):
6 """
7 >>> cclass().test_self()
8 'cclass'
9 """
10 return cython.typeof(self)
12 def test_self_1(self, arg):
13 """
14 >>> cclass().test_self_1(1)
15 ('cclass', 1)
16 """
17 return cython.typeof(self), arg
19 def test_self_args(self, *args):
20 """
21 >>> cclass().test_self_args(1,2,3)
22 ('cclass', (1, 2, 3))
23 """
24 return cython.typeof(self), args
26 def test_args(*args):
27 """
28 >>> cclass().test_args(1,2,3)
29 ('Python object', (1, 2, 3))
30 """
31 return cython.typeof(args[0]), args[1:]
33 def test_args_kwargs(*args, **kwargs):
34 """
35 >>> cclass().test_args_kwargs(1,2,3, a=4)
36 ('Python object', (1, 2, 3), {'a': 4})
37 """
38 return cython.typeof(args[0]), args[1:], kwargs
