[Python-ideas] String formatting and namedtuple
Eric Smith
eric at trueblade.com
Tue Feb 17 13:36:30 CET 2009
Eric Smith wrote:
> I have this mostly implemented in ''.format(), despite my earlier
> statement that I was done playing with it after the sample that's
> attached to http://bugs.python.org/issue5237.
The one issue that's causing me problems is what to do with format
specifiers that themselves need expanding.
>>> '{0:>{1}}'.format('foo', 5)
' foo'
Should:
>>> '{:{}}'.format('foo', 5)
produce the same output, or should it be an error? I think it should
probably work, but it complicates the implementation sufficiently that I
probably won't be able to finish it up for a couple of weeks.
I know this is a not-so-useful corner case, but the implementation has
to do something here. I could easily throw an exception, but I don't see
how that's more desirable than just making it work.
More information about the Python-ideas
mailing list