Commit 7560a9e7 authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Moved a code snippet from cdef_classes.rst to the examples directory to add it to the tests.

parent 5fadf79e
class MathFunction(object):
def __init__(self, name, operator):
self.name = name
self.operator = operator
def __call__(self, *operands):
return self.operator(*operands)
...@@ -2,15 +2,9 @@ Extension types (aka. cdef classes) ...@@ -2,15 +2,9 @@ Extension types (aka. cdef classes)
=================================== ===================================
To support object-oriented programming, Cython supports writing normal To support object-oriented programming, Cython supports writing normal
Python classes exactly as in Python:: Python classes exactly as in Python:
class MathFunction(object): .. literalinclude:: ../../examples/tutorial/cdef_classes/math_function.py
def __init__(self, name, operator):
self.name = name
self.operator = operator
def __call__(self, *operands):
return self.operator(*operands)
Based on what Python calls a "built-in type", however, Cython supports Based on what Python calls a "built-in type", however, Cython supports
a second kind of class: *extension types*, sometimes referred to as a second kind of class: *extension types*, sometimes referred to as
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment