[Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3

Paul Moore p.f.moore at gmail.com
Thu Sep 11 11:44:02 CEST 2014


On 11 September 2014 08:30, Steven D'Aprano <steve at pearwood.info> wrote:
>> >>> print(':'.join("{:02x}".format(c) for c in b'Abc'))
>> 41:62:63
>>
>> Not every one-liner needs to be a builtin...
>
> Until your post just now, there has probably never been anyone anywhere
> who wanted to display b'Abc' as "41:62:63", and there probably never
> will be again. For such a specialised use-case, it's perfectly justified
> to reject a request for such a colon-delimited hex function with "not
> every one-liner...".

So I picked a bad example. Sorry. Someone (sorry, I can't recall who)
did ask for

>>> print(' '.join("{:02x}".format(c) for c in b'Abc'))
41 62 63

My point is that a simple pattern is flexible, a specific method has
to pick one "obvious" representation, and there have been a number of
representations discussed here.

Paul


More information about the Python-ideas mailing list