[Tutor] capitalize() but only first letter
Jeff Shannon
jeff@ccvcorp.com
Thu Feb 6 14:42:02 2003
Erik Price wrote:
> I'm still somewhat confused since I would think that the following
> tuple uses four throwaway objects (three strings and the tuple
> itself), but I can see that you don't add an "additional" intermediate
> string between each string element of the tuple when you use join().
>
> t = ("first", "second", "third")
But those three strings are your source strings, and are necessarily
present in *any* concatenation.
t = "first" + "second" + "third"
has those same three strings, plus it generates the string "firstsecond"
which is thrown away, before creating the complete string which is bound
to t. (Yes, this does seem to imply that only when there are more than
two string additions would the sprintf-style formatting be likely to
yield notable performance benefits, but I would still argue that it's
preferable for appearance and consistency.)
Jeff Shannon
Technician/Programmer
Credit International