Ethan Furman <[email protected]>:
> Can anybody think of a use-case for this particular feature?
Internet protocol entities constantly have to format (and parse)
ASCII-esque octet strings:
headers.append(b'Content-length: %d\r\n' % len(blob))
headers.append(b'Content-length: {}\r\n'.format(len(blob)))
Now you must do:
headers.append(('Content-length: %d\r\n' % len(blob)).encode())
headers.append('Content-length: {}\r\n'.format(len(blob)).encode())
That is:
1. ineffient (encode/decode shuffle)
2. unnatural (strings usually have no place in protocols)
3. confusing (what is stored as bytes, what is stored as strings?)
4. error-prone (UTF-8 decoding exceptions etc)
To be sure, %s will definitely be needed as well:
uri = b'http://%s/robots.txt' % host
Marko
--
https://mail.python.org/mailman/listinfo/python-list