This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Comparisons difference: bytes with bytes, str with str
Type: behavior Stage: resolved
Components: Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, ivb
Priority: normal Keywords:

Created on 2012-12-20 13:49 by ivb, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg177817 - (view) Author: Ivan Bykov (ivb) Date: 2012-12-20 13:49
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> b = b't'
>>> b[0] in [b]
False
>>> u = 't'
>>> u[0] in [u]
True
msg177819 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-12-20 13:55
That's the correct behaviour. Iteration and item access of bytes don't return bytes but a small number, e.g. b[0] returns 116 and not b't'.

>>> b = b't'
>>> b[0]  in [b]
False
>>> b[0]
116
>>> ord(b)
116

But:
>>> b in [b]
True
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60942
2012-12-20 13:55:34christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg177819

resolution: not a bug
stage: resolved
2012-12-20 13:49:38ivbcreate