[issue21177] ValueError: byte must be in range(0, 256)

2014-04-11 Thread Stefan Krah
Stefan Krah added the comment: Antoine Pitrou wrote: > > I suggested "must be in the range [0; 255]" which is not a valid Python > > list: ";" is the instruction operator and there is "range" word in front of > > the "list". In my opinion, it's much easier to read and understand it. > > I'm -1

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, seeing how the alternative proposals are all worse than the statu quo, and how this is going a massive bikeshedding anyway, I'd rather close the issue. -- resolution: -> invalid status: open -> closed ___ Python

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I suggested "must be in the range [0; 255]" which is not a valid Python > list: ";" is the instruction operator and there is "range" word in front of > the "list". In my opinion, it's much easier to read and understand it. I'm -1 on it. It may not be a valid P

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-11 Thread Mark Lawrence
Mark Lawrence added the comment: How about plain English? "byte must be between 0 and 255 inclusive" -- nosy: +BreamoreBoy ___ Python tracker ___ ___

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-11 Thread akira
akira added the comment: "byte must be in range [0, 256)" - it hints at the builtin `range()` -- the intuition works for those who knows what `range()` does - it uses the standard math notation for half-open intervals [1] -- no Python knowledge required (among other things) - it is not a valid

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-11 Thread STINNER Victor
STINNER Victor added the comment: I suggested "must be in the range [0; 255]" which is not a valid Python list: ";" is the instruction operator and there is "range" word in front of the "list". In my opinion, it's much easier to read and understand it. Another example is the Unicode range(0x1100

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Yet this error message still gave me a "wtf" moment because I didn't realize it was talking about python's range() builtin and not about mathematical term. So even though this message is technically 100% correct it still doesn't feel right. If that "wtf" momen

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-10 Thread Konstantin Zemlyak
Konstantin Zemlyak added the comment: To clarify few things: - Yes, I know that 256 doesn't fit into byte. I was checking how bytes/bytearray are handling overflow. - I know that range() is a half-open interval. Yet this error message still gave me a "wtf" moment because I didn't realize it w

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-10 Thread Stefan Krah
Stefan Krah added the comment: There's no real problem. I find "must be in the range [0, 255]" easier to understand, but I also would not make a big effort to change this. As for me, we can close this issue. -- ___ Python tracker

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: > There's no real problem. I find "must be in the range [0, 255]" easier to > understand, but I also would not make a big effort to change this. The problem is that [0, 255] looks very much like a Python list, not a range. -- _

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: Uh, from the context, it's clear that the error is that 256 doesn't fit in the average 8-bits byte. Is there an actual problem here? (if you don't know what a byte is, you probably shouldn't use that form of the bytes() constructor) -- nosy: +pitrou

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread STINNER Victor
STINNER Victor added the comment: > The math-inspired notation [0, 255] may be misinterpreted as a list. You also > lose the consistency of preferring half-open intervals everywhere. Not if you write "x must in the range [0; 255]". -- ___ Python tra

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread Peter Otten
Peter Otten added the comment: As every beginner will learn about (and probably overuse) range() pretty soon I think it's OK to use that form. The math-inspired notation [0, 255] may be misinterpreted as a list. You also lose the consistency of preferring half-open intervals everywhere. The

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread STINNER Victor
STINNER Victor added the comment: "Perhaps we should just use closed intervals of the form [0, 255] everywhere." I only saw range(0, 256) in Python. At school, I used [0, 255]. I prefer [0, 255] syntax, it's more explicit :-) -- ___ Python tracker

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread Stefan Krah
Stefan Krah added the comment: I think it's possible to misunderstand this error message if the reader does not realize that range(0, 256) is to be taken literally. Perhaps we should just use closed intervals of the form [0, 255] everywhere. -- nosy: +skrah

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread STINNER Victor
STINNER Victor added the comment: 256 is not part of the range(0, 256): 0..255. $ python >>> print(list(range(0,256))) [0, 1, 2, 3, ..., 253, 254, 255] It doesn't make sense to store the number 256 in a byte string. -- nosy: +haypo ___ Python tracke

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread Konstantin Zemlyak
New submission from Konstantin Zemlyak: Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> bytearray([256]) Traceback (most recent call last): File "", line 1, in ValueError: