On Thu, Mar 27, 2014 at 3:47 AM, Victor Stinner <victor.stin...@gmail.com>wrote:

> The PEP 461 looks good to me. It's a nice addition to Python 3.5 and
> the PEP is well defined.
>

+1


> I can help to implement it. Maybe, it would be nice to provide an
> implementation as a third-party party module on PyPI for Python
> 2.6-3.4.
>

That is possible and would enable bytes formatting on earlier 3.x versions.
I'm not sure if there is any value in backporting to 2.x as those already
have such formatting with Python 2's str.__mod__ % operator.

Though I don't know what it'd look like as an API as a module.
Brainstorming: It'd either involve function calls to format instead of % or
a container class to wrap format strings in with a __mod__ method that
calls the bytes formatting code instead of native str % formatting when
needed.

>From a 2.x-3.x compatible code standpoint the above could exist but the
container class constructor would be a no-op on Python 2.
  if sys.version_info[0] == 2:
    BytesFormatter = str
  else:
    class BytesFormatter: ... def __mod__ ...

-gps


> Note: I fixed a typo in your PEP (reST syntax).
>
> Victor
>
> 2014-03-26 23:47 GMT+01:00 Ethan Furman <et...@stoneleaf.us>:
> >> This one is wrong:
> >>
> >>>>> repr(b'abc').encode('ascii', 'backslashreplace')
> >>
> >> b"b'abc'"
> >
> >
> > Fixed, thanks.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/greg%40krypto.org
>
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to