Eryk Sun <eryk...@gmail.com> added the comment:

>    \N{name}   : named character
>    \UXXXXXXXX : 32-bit hexadecimal ordinal (e.g. \U0010ffff)
>    \uXXXX     : 16-bit hexadecimal ordinal (e.g. \uffff)
>    \xXX       : 8-bit hexadecimal ordinal (e.g. \xff)
>    \OOO       : 9-bit octal ordinal (e.g. \777)
>    \OO        : 6-bit octal ordinal (e.g. \77)
>    \O         : 3-bit octal ordinal (e.g. \7)

Note that bytes literals do not implement \N, \U, and \u escape sequences -- 
e.g. b'\N{SPACE}' is literally just those 9 bytes, not b' '. Also, in bytes 
literals 9-bit octal sequences wrap around for the [256, 511] range -- e.g. 
b'\400' ==  b'\000' == b'\x00' and b'\777' == b'\377' == b'\xff'. I don't know 
whether the latter is intentional. I'd prefer for the compiler to raise a 
syntax error in this case. Asking for a byte value in the range [256, 511] is 
nonsense.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37939>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to