Add a warning text about mixing bytes and strings.

This commit is contained in:
Georg Brandl 2007-09-01 12:08:51 +00:00
parent 37f10386f1
commit 2326a79de1
1 changed files with 6 additions and 0 deletions

View File

@ -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