New Python 3.0 string formatting - really necessary?

skip at pobox.com skip at pobox.com
Sun Dec 21 09:59:53 EST 2008


    Marc> Many newbie code I have seen avoids it by string concatenation:

    Marc> greeting = 'Hello, my name is ' + name + ' and I am ' + str(age) + ' old.'

    Marc> That's some kind of indirect complaint.  :-)

I see Python code like that written by people with a C/C++ background.  I
don't think you can necessarily chalk that up to %-string avoidance.  They
learn that + will concatenate two strings and don't look further.

-- 
Skip Montanaro - skip at pobox.com - http://smontanaro.dyndns.org/



More information about the Python-list mailing list