Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
04260b51
Commit
04260b51
authored
6 years ago
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved a code snippet to the examples directory.
parent
084a25f5
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
+15
-0
docs/src/userguide/wrapping_CPlusPlus.rst
docs/src/userguide/wrapping_CPlusPlus.rst
+2
-5
No files found.
docs/examples/userguide/wrapping_CPlusPlus/iterate.pyx
0 → 100644
View file @
04260b51
# distutils: language = c++
from
libcpp.vector
cimport
vector
def
main
():
cdef
vector
[
int
]
v
cdef
int
i
,
value
for
i
in
range
(
10
):
v
.
push_back
(
i
)
for
value
in
v
:
print
(
value
)
return
[
x
*
x
for
x
in
v
if
x
%
2
==
0
]
This diff is collapsed.
Click to expand it.
docs/src/userguide/wrapping_CPlusPlus.rst
View file @
04260b51
...
@@ -413,12 +413,9 @@ inside of containers, e.g. a C++ vector of maps of strings.
...
@@ -413,12 +413,9 @@ inside of containers, e.g. a C++ vector of maps of strings.
Iteration over stl containers (or indeed any class with ``begin()`` and
Iteration over stl containers (or indeed any class with ``begin()`` and
``end()`` methods returning an object supporting incrementing, dereferencing,
``end()`` methods returning an object supporting incrementing, dereferencing,
and comparison) is supported via the ``for .. in`` syntax (including in list
and comparison) is supported via the ``for .. in`` syntax (including in list
comprehensions). For example, one can write:
:
comprehensions). For example, one can write:
cdef vector[int] v = ...
.. literalinclude:: ../../examples/userguide/wrapping_CPlusPlus/iterate.pyx
for value in v:
f(value)
return [x*x for x in v if x % 2 == 0]
If the loop target variable is unspecified, an assignment from type
If the loop target variable is unspecified, an assignment from type
``*container.begin()`` is used for :ref:`type inference <compiler-directives>`.
``*container.begin()`` is used for :ref:`type inference <compiler-directives>`.
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment