Commit 03337615 authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Moved the first code snippet of the extension_types.rst to the examples directory for testing.

parent f1815e7b
from __future__ import print_function
cdef class Shrubbery:
cdef int width, height
def __init__(self, w, h):
self.width = w
self.height = h
def describe(self):
print("This shrubbery is", self.width,
"by", self.height, "cubits.")
...@@ -12,21 +12,9 @@ Introduction ...@@ -12,21 +12,9 @@ Introduction
As well as creating normal user-defined classes with the Python class As well as creating normal user-defined classes with the Python class
statement, Cython also lets you create new built-in Python types, known as statement, Cython also lets you create new built-in Python types, known as
extension types. You define an extension type using the :keyword:`cdef` class extension types. You define an extension type using the :keyword:`cdef` class
statement. Here's an example:: statement. Here's an example:
from __future__ import print_function .. literalinclude:: ../../examples/userguide/extension_types/shrubbery.pyx
cdef class Shrubbery:
cdef int width, height
def __init__(self, w, h):
self.width = w
self.height = h
def describe(self):
print("This shrubbery is", self.width,
"by", self.height, "cubits.")
As you can see, a Cython extension type definition looks a lot like a Python As you can see, a Cython extension type definition looks a lot like a Python
class definition. Within it, you use the def statement to define methods that class definition. Within it, you use the def statement to define methods that
......
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