On Tue, Aug 10, 2010 at 6:22 PM, Steven D'Aprano <st...@pearwood.info>wrote:

> On Wed, 11 Aug 2010 06:09:28 am Joel Goldstick wrote:
> > The str part of str.join() is the string where the result is stored,
> > so you can start off with an empty string: ""
>
> I don't understand what you mean by that. I can only imagine you think
> that the string part is a fixed-width buffer that has the result stored
> into it, but of course that's ridiculous because that's nothing like
> what join does. Python strings are immutable so you can't store
> something inside an existing string, but even if they weren't, since
> the result of join is usually larger than the initial string you pass,
> what would be the point?
>
> The string part of str.join is the string which is used to join the rest
> of the arguments. This:
>
> "spam".join([ "a", "b", "c" ])
>
> is equivalent to:
>
> "a" + "spam" + "b" + "spam" + "c"
>
> except more efficient and faster. The result is stored in a new string.
>
>
>
> --
> Steven D'Aprano
>
> Steve, thanks for correcting me. The str being the 'glue' that joins
between each of the list members.
-- 
Joel Goldstick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to