[Python-3000] PEP 3101 Updated

James Thiele python3now at gmail.com
Wed Aug 15 16:52:32 CEST 2007


The section on the explicit conversion flag contains the following line:

      These flags are typically placed before the format specifier:

Where else can they be placed?

Also there is no description of what action (if any) is taken if an
unknown explicit conversion flag is encoubtered.

On 8/15/07, Eric Smith <eric+python-dev at trueblade.com> wrote:
> Talin wrote:
> > A new version is up, incorporating material from the various discussions
> > on this list:
> >
> >       http://www.python.org/dev/peps/pep-3101/
>
> I have a number of parts of this implemented.  I'm refactoring the
> original PEP 3101 sandbox code to get it working.  Mostly it involves
> un-optimizing string handling in the original work :(
>
> These tests all pass:
>
> self.assertEquals('{0[{1}]}'.format('abcdefg', 4), 'e')
> self.assertEquals('{foo[{bar}]}'.format(foo='abcdefg', bar=4), 'e')
> self.assertEqual("My name is {0}".format('Fred'), "My name is Fred")
> self.assertEqual("My name is {0[name]}".format(dict(name='Fred')),
>                   "My name is Fred")
> self.assertEqual("My name is {0} :-{{}}".format('Fred'),
>                   "My name is Fred :-{}")
>
> I have not added the !r syntax yet.
>
> I've only spent 5 minutes looking at this so far, but I can't figure out
> where to add a __format__ to object.  If someone could point me to the
> right place, that would be helpful.
>
> Thanks.
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/python3now%40gmail.com
>


More information about the Python-3000 mailing list