Skip to content

Commit

Permalink
add explicit section about literal prefixes to strings tutorial (and …
Browse files Browse the repository at this point in the history
…mention PEP 498 in it)
  • Loading branch information
scoder committed Mar 26, 2016
1 parent 60332ba commit 480bf89
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docs/src/tutorial/strings.rst
Expand Up @@ -55,10 +55,25 @@ Python 2 for backwards compatibility reasons. It is not compatible with
the :obj:`bytes` type. Its usage should be rare in normal Cython code as
the generic :obj:`object` type (i.e. untyped code) will normally be good
enough and has the additional advantage of supporting the assignment of
string subtypes. Support for the :obj:`basestring` type is new in Cython
string subtypes. Support for the :obj:`basestring` type was added in Cython
0.20.


String literals
---------------

Cython understands all Python string type prefixes:

* ``b'bytes'`` for byte strings
* ``u'text'`` for Unicode strings
* ``f'formatted {value}'`` for formatted Unicode string literals as defined by
`PEP 498 <https://www.python.org/dev/peps/pep-0498/>`_ (added in Cython 0.24)

Unprefixed string literals become :obj:`str` objects when compiling
with language level 2 and :obj:`unicode` objects (i.e. Python 3
:obj:`str`) with language level 3.


General notes about C strings
-----------------------------

Expand Down

0 comments on commit 480bf89

Please sign in to comment.