[Tutor] capitalize() but only first letter
Sean 'Shaleh' Perry
shalehperry@attbi.com
Wed Feb 5 23:46:02 2003
On Wednesday 05 February 2003 19:54, Erik Price wrote:
> On Wednesday, February 5, 2003, at 10:31 PM, Jeff Shannon wrote:
> > I suspect that Sean finds the string method syntax of join() to be
> > awkward (there was quite a bit of discussion when this was added to
> > Python, and many people still disagree with Guido's decision), but I
> > find it less awkward than needlessly importing the string module. ;)
>
> I also prefer to use methods of objects rather than pass objects to
> functions, but it seems like six on one side, half a dozen on the
> other. I find methods a little simpler. (This actually raises another
> question that I wanted to ask, but it's so unrelated to this thread
> that I'll spawn a new one.)
>
I personally find ''.join() awkward to read. Is that "join with an empty=
=20
string" or "join with a space"? Very rarely do we see other=20
"string".method() style invocations. If I had to (and I almost did in my=
=20
first email) I would do:
space =3D ' '
output =3D space.join(list)
> >> Finally, how does this compare:
> >>
> >> print("%s %s") % ('hello', 'world')
> >
> > This is much preferable, at least to my tastes. It still avoids the
> > creating of multiple intermediate strings
>
> Let me just play devil's advocate here then, because I'm a little
> confused -- if it avoids creating multiple intermediate strings, then
> what would those elements of the tuple be? They are not references to
> string objects? (I sound obstinate here but I'm trying to be curious.)
>
yes it generates a throw away tuple. Not quite as bad as a list, but it =
does=20
create that object.