Commit 52f629d4 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2412 from gabrieldemarmiesse/test_language_basics_2

Added tests for "language basics" part 2
parents 6529f9bc 9426f662
...@@ -107,21 +107,9 @@ You can declare classes with :keyword:`cdef`, making them :ref:`extension-types` ...@@ -107,21 +107,9 @@ You can declare classes with :keyword:`cdef`, making them :ref:`extension-types`
have a behavior very close to python classes, but are faster because they use a ``struct`` have a behavior very close to python classes, but are faster because they use a ``struct``
internally to store attributes. internally to store attributes.
Here is a simple example:: Here is a simple 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.")
You can read more about them in :ref:`extension-types`. You can read more about them in :ref:`extension-types`.
......
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