Commit 01198ace authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2337 from gabrieldemarmiesse/pure_python_mode_4

Adding tests for "pure python mode" part 4
parents 27b8f4ee 59b13ab0
import cython
x = cython.declare(cython.int) # cdef int x
y = cython.declare(cython.double, 0.57721) # cdef double y = 0.57721
import cython
cython.declare(x=cython.int, y=cython.double) # cdef int x; cdef double y
...@@ -122,14 +122,13 @@ Static typing ...@@ -122,14 +122,13 @@ Static typing
* ``cython.declare`` declares a typed variable in the current scope, which can be * ``cython.declare`` declares a typed variable in the current scope, which can be
used in place of the :samp:`cdef type var [= value]` construct. This has two forms, used in place of the :samp:`cdef type var [= value]` construct. This has two forms,
the first as an assignment (useful as it creates a declaration in interpreted the first as an assignment (useful as it creates a declaration in interpreted
mode as well):: mode as well):
x = cython.declare(cython.int) # cdef int x .. literalinclude:: ../../examples/tutorial/pure/cython_declare.py
y = cython.declare(cython.double, 0.57721) # cdef double y = 0.57721
and the second mode as a simple function call:: and the second mode as a simple function call:
cython.declare(x=cython.int, y=cython.double) # cdef int x; cdef double y .. literalinclude:: ../../examples/tutorial/pure/cython_declare2.py
It can also be used to type class constructors:: It can also be used to type class constructors::
......
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