[Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5

Nick Coghlan ncoghlan at gmail.com
Fri Jan 10 02:32:05 CET 2014


On 10 Jan 2014 03:32, "Antoine Pitrou" <solipsis at pitrou.net> wrote:
>
> On Fri, 10 Jan 2014 05:26:04 +1000
> Nick Coghlan <ncoghlan at gmail.com> wrote:
> >
> > We should probably include format_map for consistency with the str API.
>
> Yes, you're right.
>
> > >However, I
> > > also added bytearray into the mix, as bytearray objects should
> > > generally support the same operations as bytes (and they can be useful
> > > *especially* for network programming).
> >
> > So we'd define the *format* string as mutable to get a mutable result
out
> > of the formatting operations? This seems a little weird to me.
> >
> > It also seems weird for a format method on a mutable type to *not*
perform
> > in-place mutation.
>
> It's consistent with bytearray.join's behaviour:
>
> >>> x = bytearray()
> >>> x.join([b"abc"])
> bytearray(b'abc')
> >>> x
> bytearray(b'')

Yeah, I guess I'm OK with us being consistent on that one. It's still
weird, but also clearly useful :)

Will the new binary format ever call __format__? I assume not, but it's
probably best to make that absolutely explicit in the PEP.

Cheers,
Nick.

>
>
> Regards
>
> Antoine.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140110/07e02111/attachment.html>


More information about the Python-Dev mailing list