[Python-Dev] transitioning from % to {} formatting

Terry Reedy tjreedy at udel.edu
Mon Oct 5 06:43:05 CEST 2009


Carl Trachte wrote:

>> I've skimmed over the PEP, and the new {}-syntax seems to have some nice
>> features. But I've not seen it used anywhere yet.

I am using it with 3.1 in an unreleased book I am still writing, and 
will in any code I publish.

> <delurk>
> 
> Rami Chowdhury posted this to a mailing list; I've been using it
> (perhaps unintentionally promoting it) as part of non-English,
> non-ASCII font outreach:
> 
>> def শালাম_বল(নাম):
>>    কথা = "শালাম {0}. কেমন আছেন?".format(নাম)
>>    print(কথা)
>>
>> def say_greeting(name):
>>   to_say = "Greetings, {0}. How are you?".format(name)
>>   print(to_say)
> 
> As a user, my assumption was {} was going forward, rain or shine, and
> everyone should be on board by Python 3.2.

Autonumbering, added in 3.1, makes '{}' as easy to write for simple 
cases as '%s'. That was one complaint about the original 3.0 version. 
Another was and still is the lack of conversion, which is being worked on.

   (I thought once the Talin
> PEP got approved, that was it).  I wrote Steven Bethard privately
> about this.
> 
> Sorry for the intrusion.
> 
> </delurk>

tjr



More information about the Python-Dev mailing list