Cult-like behaviour [was Re: Kindness]
marko at pacujo.net
Tue Jul 17 09:14:41 EDT 2018
Rhodri James <rhodri at kynesim.co.uk>:
> On 17/07/18 02:17, Steven D'Aprano wrote:
>> Ah yes, the unfortunate design error that iterating over byte-strings
>> returns ints rather than single-byte strings.
>> That decision seemed to make sense at the time it was made, but turned
>> out to be an annoyance. It's a wart on Python 3, but fortunately one
>> which is fairly easily dealt with by a helper function.
> I don't think I agree with you, but that may just be my heritage as a C
> programmer. Every time I've iterated over a byte string, I've really
> meant bytes (as in integers). Those bytes may correspond to ASCII
> characters, but that's just a detail.
The practical issue is how you refer to ASCII bytes. What I've resorted
if nxt == b":":
Alternatively, I *could* write:
if nxt in b":":
What's your favorite way of expressing character constants?
More information about the Python-list