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

akira report at bugs.python.org
Fri Apr 11 17:25:02 CEST 2014


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 Python -- no confusion with a list, tuple literals
- Dijkstra explains why half-open intervals are preferable [2]

Another alternative is to use `range(0x100)` and require that to understand the error message, you should know Python and the hex notation.

[1]: http://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals
[2]: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

----------
nosy: +akira

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21177>
_______________________________________


More information about the Python-bugs-list mailing list