mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
Add a warning text about mixing bytes and strings.
This commit is contained in:
parent
37f10386f1
commit
2326a79de1
1 changed files with 6 additions and 0 deletions
|
|
@ -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 *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be a bytes
|
||||||
object of length 1.
|
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,
|
Lists are constructed with square brackets, separating items with commas: ``[a,
|
||||||
b, c]``. Tuples are constructed by the comma operator (not within square
|
b, c]``. Tuples are constructed by the comma operator (not within square
|
||||||
brackets), with or without enclosing parentheses, but an empty tuple must have
|
brackets), with or without enclosing parentheses, but an empty tuple must have
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue