Refer to PEP 3137 and PEP 358.

Bytes objects are for conveying binary data (or encoded strings). Such binary 
data is customary specified in hex-dump or base64 format in source files.
It would be nice to introduce a way in python to do that 'natively' (at lexical 
analysis time) using x-strings and y-strings (in lieu of f-strings).

x-strings:

                x"0123456789abcdef"  (x-prefixed quoted string of even-numbered 
amount of characters of the set [0-9a-fA-F], whitespace ignored)
equivalent to:
                b"\x01\x23\x45\x67\x89\xab\xcd\xef"  (but more readable)

y-strings:

                y"ASNFZ4mrze8=" (y-prefixed quoted string of valid base64, 
whitespace ignored)
equivalent to:
                b"\x01\x23\x45\x67\x89\xab\xcd\xef"  (but shorter)

This is not a replacement of the hex/base64 encoding, binascii packages etc. It 
just gives the programmer more freedom to specify literal bytes objects in the 
source code.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/VGXARYOPWYXUVGF6FA4DPMHCKIQVQF6L/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to