Kay Schluehr wrote:

> This yields the hexadecimal representation of the ASCII character and
> does not simply echo the keystrokes '\' and 'a' for '\a' ignoring the
> escape semantics. One way to achieve this naturally is by prefixing
> '\a' with r where r'\a' indicates a "raw" string. But unfortunately
> "rawrification" applies only to string literals and not to string
> objects ( such as c ). I consider creating a table consisting of pairs
> {'\0': r'\0','\1': r'\1',...}  i.e. a handcrafted mapping but maybe
> I've overlooked some simple function or trick that does the same for
> me.

if not else, you've missed that octal escapes consists of three digits, 
not one, so translating chr(1) to r"\1" doesn't work in the general case 
(e.g. len("\100") == 1, not 3)

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to