[issue3982] support .format for bytes

Martin v. Löwis report at bugs.python.org
Mon Sep 29 23:33:09 CEST 2008


Martin v. Löwis <martin at v.loewis.de> added the comment:

>> I think Martin's suggesting of encoding back to ascii might be 
>> the best thing to do
> 
> As I understand, you would like to use bytes as characters, like 
> b'{code} {message}'.format(code=100, message='OK'). So why no using 
> explicit conversion to ASCII? ftp='{code} {message}'.format(code=100, 
> message='OK').encode('ASCII').

That's indeed exactly what I had proposed - only that you shouldn't
repeat the .encode('ascii') all over the place, but instead wrap that
into a function (which I proposed to call push_string, along with the
existing .push function.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3982>
_______________________________________


More information about the Python-bugs-list mailing list