diff options
author | Georg Brandl <georg@python.org> | 2007-09-01 12:08:51 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-09-01 12:08:51 +0000 |
commit | e4dc8a67fae4c98497c525182e27f23086dab8e1 (patch) | |
tree | 1bf8ed8dc53758256819fa7e7cec4ce128043b05 /Doc | |
parent | f9b4f831dc229518e0066e2f167103cbd416ee88 (diff) | |
download | cpython-e4dc8a67fae4c98497c525182e27f23086dab8e1.tar.gz |
Add a warning text about mixing bytes and strings.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/stdtypes.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 96c0b269ba..93d00a3640 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -515,6 +515,12 @@ constructed from literals too; use a ``b`` prefix with normal string syntax: object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be a bytes object of length 1. + Also, while in previous Python versions, byte strings and Unicode strings + could be exchanged for each other rather freely (barring encoding issues), + strings and bytes are completely separate concepts. There's no implicit + en-/decoding if you pass and object of the wrong type or try to e.g. compare + a string with a bytes object. + Lists are constructed with square brackets, separating items with commas: ``[a, b, c]``. Tuples are constructed by the comma operator (not within square brackets), with or without enclosing parentheses, but an empty tuple must have |