Edit: I'm talking about behavior in Python 2.7.
The chr function converts integers from 0 to 127 to ASCII characters. For example.
>>> chr(65) 'A'
I understand how useful this is in certain situations, and I understand why it covers 0..127, a 7-bit ASCII range.
The function also takes arguments from 128..255. For these numbers, it simply returns the hexadecimal representation of the argument. In this range, different bytes mean different things, depending on which part of the ISO-8859 standard is used.
I would understand if chr accepted another argument, for example
>>> chr(228, encoding='iso-8859-1')
However, there is no such option:
chr(i) -> character Return a string of one character with ordinal i; 0 <= i < 256.
My questions are: what is the point of raising a ValueError for i > 255 instead of i > 127 ? All functions for 128 <= i < 256 are hexadecimal return values?
python ascii
lmichelbacher
source share