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

Carl Trachte ctrachte at gmail.com
Fri Oct 2 22:23:11 CEST 2009


>> Do the users get any say in this?
>
> I'm a user! :-)
>
> I hate calling methods on string literals, I think it looks very odd to
> have code like this:
>
>   "Displaying {0} of {1} revisions".format(x, y)
>
> Will we be able to write this as
>
>   "Displaying {0} of {1} revisions" % (x, y)
>
> too?
>
>> I imagine that some people are heavily invested in %-formatting.
>>
>> Because there has been limited uptake on {}-formatting (afaict), we
>> still have limited experience with knowing that it is actually better,
>> less error-prone, easier to learn/rember, etc. Outside a handful of
>> people on this list, I have yet to see anyone adopt it as the
>> preferred syntax.
>
> 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.
>

<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.  (I thought once the Talin
PEP got approved, that was it).  I wrote Steven Bethard privately
about this.

Sorry for the intrusion.

</delurk>


More information about the Python-Dev mailing list