diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-03 15:40:29 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-03 15:40:29 +0200 |
| commit | 5aec69ed290552e7ea20bdef416c5bc23f6231f8 (patch) | |
| tree | 4b557eeb5f5dfcfa8c8042ee8adea86fcfb6ed33 /docs/topics/python3.txt | |
| parent | 9908201d7fc3340b83db21298033c5b347f38d65 (diff) | |
Documented the trick used in 9908201d7f.
Diffstat (limited to 'docs/topics/python3.txt')
| -rw-r--r-- | docs/topics/python3.txt | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/docs/topics/python3.txt b/docs/topics/python3.txt index 3f799edac7..b09c1d2347 100644 --- a/docs/topics/python3.txt +++ b/docs/topics/python3.txt @@ -36,6 +36,11 @@ In order to enable the same behavior in Python 2, every module must import my_string = "This is an unicode literal" my_bytestring = b"This is a bytestring" +If you need a byte string under Python 2 and a unicode string under Python 3, +use the :func:`str` builtin:: + + str('my string') + Be cautious if you have to `slice bytestrings`_. .. _slice bytestrings: http://docs.python.org/py3k/howto/pyporting.html#bytes-literals |
