[Python-ideas] duck typing for io write methods
Oscar Benjamin
oscar.j.benjamin at gmail.com
Thu Jun 13 15:57:01 CEST 2013
On 13 June 2013 13:24, Nick Coghlan <ncoghlan at gmail.com> wrote:
> If your type is acceptable input to operator.index(), you'll get the
> "initialised array of bytes" behaviour
I only recently discovered this. What was the rationale for that change?
$ py -2.7 -c 'print(repr(bytes(4)))'
'4'
$ py -3.3 -c 'print(repr(bytes(4)))'
b'\x00\x00\x00\x00'
I can't really see why anyone would want the latter behaviour (when
you can already do b'\x00' * 4).
Oscar
More information about the Python-ideas
mailing list