Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-25 Thread Mark Lawrence
On 25/02/2014 08:07, wxjmfa...@gmail.com wrote: What is wrong by design will always stay wrong by design. Why are you making the statement that PEP 461 is wrong by design? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawre

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-25 Thread wxjmfauth
Le mardi 25 février 2014 00:55:36 UTC+1, Steven D'Aprano a écrit : > > > > However, you don't really want to be adding large numbers of byte strings > > together, due to efficiency. Better to use % interpolation to insert them > > all at once. Hence the push to add % to bytes in Python 3. >

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Steven D'Aprano
On Mon, 24 Feb 2014 16:10:53 -0800, Ethan Furman wrote: > On 02/24/2014 03:55 PM, Steven D'Aprano wrote: >> Will b'%s' take any arbitrary object, as in: >> >> b'Key: %s' % [1, 2, 3, 4] >> => b'Key: [1, 2, 3, 4]' > > No. Very glad to hear it. [...] >>> Can anybody think of a use-case for this

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Ethan Furman
On 02/24/2014 03:55 PM, Steven D'Aprano wrote: On Mon, 24 Feb 2014 11:54:54 -0800, Ethan Furman wrote: Greetings! A PEP is under discussion to add %-interpolation back to the bytes type in Python 3.5. Assuming the PEP is accepted, what *will* be added back is: Numerics: b'%d' % 10 -->

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Steven D'Aprano
On Tue, 25 Feb 2014 00:18:53 +0200, Marko Rauhamaa wrote: > random...@fastmail.us: > >> On Mon, Feb 24, 2014, at 15:46, Marko Rauhamaa wrote: >>> That is: >>> >>> 1. ineffient (encode/decode shuffle) >>> >>> 2. unnatural (strings usually have no place in protocols) >> >> That's not at all cle

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Steven D'Aprano
On Mon, 24 Feb 2014 11:54:54 -0800, Ethan Furman wrote: > Greetings! > > A PEP is under discussion to add %-interpolation back to the bytes type > in Python 3.5. > > Assuming the PEP is accepted, what *will* be added back is: > > Numerics: > >b'%d' % 10 --> b'10' >b'%02x' % 10 --> b'

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Ethan Furman
On 02/24/2014 01:04 PM, random...@fastmail.us wrote: On Mon, Feb 24, 2014, at 15:46, Marko Rauhamaa wrote: That is: 1. ineffient (encode/decode shuffle) 2. unnatural (strings usually have no place in protocols) That's not at all clear. Why _aren't_ these protocols considered text protoco

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Marko Rauhamaa
random...@fastmail.us: > On Mon, Feb 24, 2014, at 15:46, Marko Rauhamaa wrote: >> That is: >> >> 1. ineffient (encode/decode shuffle) >> >> 2. unnatural (strings usually have no place in protocols) > > That's not at all clear. Why _aren't_ these protocols considered text > protocols? Why can't

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread random832
On Mon, Feb 24, 2014, at 15:46, Marko Rauhamaa wrote: > That is: > > 1. ineffient (encode/decode shuffle) > > 2. unnatural (strings usually have no place in protocols) That's not at all clear. Why _aren't_ these protocols considered text protocols? Why can't you add a string directly to header

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Marko Rauhamaa
Ethan Furman : > 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))) No

Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Ethan Furman
Greetings! A PEP is under discussion to add %-interpolation back to the bytes type in Python 3.5. Assuming the PEP is accepted, what *will* be added back is: Numerics: b'%d' % 10 --> b'10' b'%02x' % 10 --> b'0a' Single byte: b'%c' % 80 --> b'P' and generic: b'%s' % some_binary_