[Python-ideas] String formatting and namedtuple

spir denis.spir at free.fr
Fri Feb 13 10:20:19 CET 2009

Le Thu, 12 Feb 2009 21:13:23 -0800,
Talin <talin at acm.org> a écrit :

> Secondly, there is an argument to be made towards moving away from any 
> syntactical pattern that requires the programmer to synchronize two 
> lists, in this case the set of '%' field markers in the string and the 
> sequence of replacement values. Having to maintain a correspondence 
> between lists is almost never a problem when code is first written, but 
> I think we can all remember instances where bugs have been introduced by 
> maintainers who added a new item to one list but forgot to add the 
> corresponding item to the other list.

I fully agree. But then the only solution is probably (re)considering a format ala Cobra:

    print 'Hello. My name is [name] and I am [age].'

[] pairs can actually hold any valid expression:

    print "Found [count(n)*3+1] items."

There were probably *very* good reasons to refuse such an obvious format.


la vida e estranya

More information about the Python-ideas mailing list