Commit b43c08b3 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2388 from gabrieldemarmiesse/test_string_13

Adding tests for "Unicode and passing strings" part 13
parents 87813c9f 9be024dc
cdef char* c_string = "Hello world"
cdef char c
for c in c_string[:11]:
if c == 'A':
print("Found the letter A")
...@@ -612,13 +612,9 @@ Iteration ...@@ -612,13 +612,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