Hi there. How about a compromise? Personally, I think adding the full complement of integer/float formatting to bytes is a bit over the top. How about just supporting two format specifiers? %b : interpolate a bytes object. If it doesn't have the buffer interface, error. %s : interpolate a str object, encoded to ASCII using 'strict' conversion. This should cover the most common use cases. In particular, you could do this: Headers.append('Content-Length: %s'%(len(data),)) And then subsequently: Packet = b'%b%b'%(b"join(headers), data) For more complex formatting, you delegate to the more capable string class, but benefit from automatic ASCII conversion: Data = b"percentage = %s" % ("%4.2f" % (value,)) I think interpolating bytes objecst is very important. And support for automatic ASCII conversion in the process will help us cover all of the numeric use cases. K -----Original Message----- From: Python-Dev [mailto:python-dev-bounces+kristjan=ccpgames.com at python.org] On Behalf Of Victor Stinner Sent: 11. janúar 2014 17:42 To: Python Dev Subject: [Python-Dev] PEP 460: allowing %d and %f and mojibake Hi, I'm in favor of adding support of formatting integer and floatting point numbers in the PEP 460: %d, %u, %o, %x, %f with padding and precision (%10d, %010d, %1.5f) and sign (%-i, %+i) but without alternate format ("{:#x}"). %s would also accept int and float for convenience.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4