> On 23 Nov 2022, at 12:32, Ronald Hoogenboom via Python-ideas > <python-ideas@python.org> wrote: > > 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.
How often would this be useful? If its rare and only nice to have I would doubt it would be added to python. I have written a lot of low level protocol and IOCTL calls that cannot think of a time this would have helped me. struct is often a mean to create blocks of binary data. Long strings of binary data would be a maintenance issue. What do all the bits mean? Barry > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > <mailto:python-ideas@python.org> > To unsubscribe send an email to python-ideas-le...@python.org > <mailto: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/
_______________________________________________ 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/XOZQHUZGRVH62HHRGMJU2ZOHWD5LGJBX/ Code of Conduct: http://python.org/psf/codeofconduct/