On 1 May 2017 at 17:19, <[email protected]> wrote: > The bytes.hex() function is the inverse function of Bytes.fromhex(). > > But fromhex can process spaces (which is much more readable), while hex() > provides no way to include spaces. > > My proposal would be to add an optional delimiter, that allows to specify a > string that will be inserted between the digit pairs of a byte: > > def hex(self, delimiter=‘‘): …
We're definitely open to offering better formatting options for bytes.hex(). My proposal in https://bugs.python.org/issue22385 was to define a new formatting mini-language (akin to the way strftime works, but with a much simpler formatting mini-language): http://bugs.python.org/issue22385#msg292663 However, a much simpler alternative would be to just support two keyword arguments to hex(): "delimiter" (as you suggest) and "chunk_size" (defaulting to 1, so you get per-byte chunking by default) Cheers, Nick. -- Nick Coghlan | [email protected] | Brisbane, Australia _______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
