[Python-Dev] Python Language Summit EuroPython 2010

Alexander Belopolsky alexander.belopolsky at gmail.com
Sun Jul 25 19:32:58 CEST 2010


On Fri, Jul 23, 2010 at 2:44 AM, Guido van Rossum <guido at python.org> wrote:
..
> Indeed, we meant b'...{}...{}...'.format(x, y). The problem is that it
> can't invoke x.__format__() or y.__format__() since those will return
> text strings instead of bytes. A proposed solution was to try
> x.__bformat__() etc. Another proposed solution was to limit x and y to
> a small set of common types and hard-code their meanings (e.g.
> numbers, bytes, and dates).

Reaching an agreement on what to hard-code for dates may be harder
than for the other common types. [1]  Implementation of
date.__bformat__ will also have it's unique challenges because at the
moment date.__format__ is date.strftime and there is no locale
independent strftime variant.

A simple solution would be to have date.__bformat__ or hard-coded
meaning to be just b'YYYY-MM-DD', but when it gets to datetime, I am
sure users will start complaining about inability to specify RFC 3339
or other internet-standard formats.

[1] http://bugs.python.org/issue8913


More information about the Python-Dev mailing list