[Python-3000] PEP 3101 Updated
Eric Smith
eric+python-dev at trueblade.com
Wed Aug 15 11:04:32 CEST 2007
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.
More information about the Python-3000
mailing list