Commit 9be024dc authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Moved an example of for loop with char* to the examples directory.

parent 04780910
cdef char* c_string = "Hello world"
cdef char c
for c in c_string[:11]:
if c == 'A':
print("Found the letter A")
...@@ -668,13 +668,9 @@ Iteration ...@@ -668,13 +668,9 @@ Iteration
Cython 0.13 supports efficient iteration over :c:type:`char*`, Cython 0.13 supports efficient iteration over :c:type:`char*`,
bytes and unicode strings, as long as the loop variable is bytes and unicode strings, as long as the loop variable is
appropriately typed. So the following will generate the expected appropriately typed. So the following will generate the expected
C code:: C code:
cdef char* c_string = ... .. literalinclude:: ../../examples/tutorial/string/for_char.pyx
cdef char c
for c in c_string[:100]:
if c == 'A': ...
The same applies to bytes objects:: The same applies to bytes objects::
......
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