[Python-3000] PEP 3101 Updated

Eric Smith eric+python-dev at trueblade.com
Wed Aug 22 18:48:43 CEST 2007


Eric Smith 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/
> 
> self.assertEquals('{0[{1}]}'.format('abcdefg', 4), 'e')
> self.assertEquals('{foo[{bar}]}'.format(foo='abcdefg', bar=4), 'e')

I've been re-reading the PEP, in an effort to make sure everything is 
working.  I realized that these tests should not pass.  The PEP says 
that "Format specifiers can themselves contain replacement fields".  The 
tests above have replacement fields in the field name, which is not 
allowed.  I'm going to remove this functionality.

I believe the intent is to support a replacement for:
"%.*s" % (4, 'how now brown cow')

Which would be:
"{0:.{1}}".format('how now brown cow', 4)

For this, there's no need for replacement on field name.  I've taken it 
out of the code, and made these tests in to errors.

Eric.



More information about the Python-3000 mailing list