[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2
victor.stinner at gmail.com
Sun Feb 23 22:56:27 CET 2014
>> (You forgot "/Uhhhhhhhh" representation (it's an antislah, but I don't
>> see the key on my Mac keyboard?).)
> Hard to forget what you don't know. ;) Will ascii() ever emit an
> antislash representation?
What is the use case of this *new* formatter? How do you use it?
> An aid to debugging -- need to see what's what at that moment? Toss it
> into %a. It is not intended for production code, but is included to
> hopefully circumvent the inappropriate use of __bytes__ methods on classes.
How do you plan to use this output? Write it into a socket or a file?
When I debug, I use print & logging which both expect text string. So I
think that b'%a' is useless.
> print(b'%a" % 123) may emit a BytesWarning and may lead to bugs.
> Why would it emit a BytesWarning?
Because print expects a text string, and print(bytes) does an implicit
conversion to Unicode. Try: python -bb -c "print(b'hello')".
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev