On Thursday, February 28, 2013 8:42:31 AM UTC-6, Helmut Jarausch wrote:

> Originally I had used percent-formatting
> But isn't  it deprecated in Python 3.X ?

I don't know the current state of "percent formats" future, however, i can tell 
you that it should be deprecated ASAP!

Simpleminded Sam blubbered: """ But rick, how will we format strings that 
contain curly braces without the "percent format" option? We can't live without 
"percent formatting", we are but simple minded folks! *sky-falling* """

Easy Sam. You allow the user to pass "opener" and "closer" chars to the format 
function.

>>> "Elvis {has} <0> the {{{ building".format('left', opener='<', closer='>')
'Elvis {has} left the {{{ building'

For strings that contain all braces you could even create something unique:

>>> "(Elvis) {has} {S}0{E} the <building>".format('left', opener='{S}', 
>>> closer='{E}')
'(Elvis) {has} left the <building>'
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to