Petitioning for bytes.format()?

Alex Gaynor agaynor at mozilla.com
Thu Jun 1 12:49:02 EDT 2017


There's no plans, even nascent, to remove str% from Python3.

I think it'd be reasonable to request CPython to add bytes.format, but I
wouldn't lose any sleep over it either.

Alex

On Thu, Jun 1, 2017 at 12:46 PM, Gregory Szorc <gregory.szorc at gmail.com>
wrote:

> bytes.format() doesn't exist in Python 3.
>
> I was watching some PyCon videos. At least one speaker made a comment that
> the % formatting operator is mainly there for backwards compatibility with
> Python 2 and str.format() is the future.
>
> If str.format() is the future and % formatting of bytes was re-added in
> Python 3.5 to facilitate consumers (like Mercurial) that do bytes
> everywhere, shouldn't bytes.format() exist to facilitate migrating away
> from the legacy % operator?
>
> Is petitioning for bytes.format() something we want to engage the Python
> community on? If there are features that don't make sense for bytes types,
> I'm sure we could settle for a subset of the feature that enabled basic
> variable insertion like the % operator.
>
> Also, in a future Python 3 only world where % is not supported or desired,
> how does one do string formatting type things for bytes anyway?
> Concatenation and io.BytesIO() are what immediately come to mind. But these
> aren't exactly elegant nor do they have decent performance. It feels like
> not having string formatting for bytes excludes bytes from the Zen of
> Python :/
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170601/5c44d143/attachment.html>


More information about the Mercurial-devel mailing list