From: Robert W. B. <rb...@di...> - 2001-04-02 16:44:40
|
Hello all, I have a question about the builtins chr(). The Python Library Reference for 2.1b2 says it "Return a string of one character whose ASCII code is the integer i, e.g., chr(97) returns the string 'a'. This is the inverse of ord(). The argument must be in the range [0..255], inclusive; ValueError will be raised if i is outside that range." When interpreting this for Jython, the obvious catches are that it specifies "range [0..255]", and raises ValueError for i outsite this range. This doesn't really seem to apply considering how Jython only has the 2-byte character string. Different behavior for Jython's builtin chr() makes sense. However, is this difference in chr() official? I didn't see a comment on http://jython.sourceforge.net/docs/differences.html about this, and I wanted to be sure before committing it to paper for a Jython publication (and risking a ValueError being raised in Jython2.1final or 2.2). Here's code in case I don't make any sense above: CPython: >>>chr(256) Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: chr() arg not in range(256) Jython: >>>chr(256) u'\u0100' Thanks, Robert |