[Python-ideas] String formatting and namedtuple
George Sakkis
george.sakkis at gmail.com
Thu Feb 12 23:40:10 CET 2009
On Thu, Feb 12, 2009 at 2:24 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> PROPOSAL: Allow the simple case to stay simple. Allow field names to be
> omitted for all fields in a string and then default to 0, 1, ... so that
> example above could be written as
>
>>>> msg = "{} == {}".format
>
> Given that computers are glorified counting machines, it *is* a bit annoying
> to be required to do the counting manually. I think this is at least half
> the objection to switching to .format.
What happens when both empty and non-empty fields appear ? E.g. would
'I love {} with {1} and {} with {1}'.format('bacon', 'eggs', 'sausage')
return 'I love bacon with eggs and eggs with eggs', or it would be
smarter and see that 1 is used explicitly and skip over it, giving 'I
love bacon with eggs and sausage with eggs' ?
George
More information about the Python-ideas
mailing list