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: bytes[0] != bytes[0:1]
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: geoffreyspear, ucyo
Priority: normal Keywords:

Created on 2018-09-26 11:43 by ucyo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg326446 - (view) Author: (ucyo) Date: 2018-09-26 11:43
bytes('sdf', 'UTF8')[0] != bytes('sdf', 'UTF8')[0:1]  # FALSE
'sdf'[0] != 'sdf'[0:1]  # TRUE

Is this a feature or bug. I would have expected the same behaviour.
msg326455 - (view) Author: Geoffrey Spear (geoffreyspear) * Date: 2018-09-26 12:11
Indexing bytes giving an int is a feature. Some might argue it's a bad feature, but it was done on purpose.
msg326456 - (view) Author: (ucyo) Date: 2018-09-26 12:15
Thank you for the answer.
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 78989
2018-09-26 12:15:13ucyosetstatus: open -> closed
resolution: not a bug
messages: + msg326456

stage: resolved
2018-09-26 12:11:00geoffreyspearsetnosy: + geoffreyspear
messages: + msg326455
2018-09-26 11:43:34ucyocreate