On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote:
> Good point. I guess I am surprised a little that Python does not error
> on that you cannot assign a variable to a module name. I know I need
> to learn proper coding techniques.
Well, that wouldn't really work because you don't know what other
modules people have.
> Okay, I can see the order of the join is the same as mine, but
> the join still seems to be out of sequence. I am thinking it should be
> 'abcABC' or 'ABCabc' not at the beginning, middle, and end of the
> original string. At least, I am trying to wrap my head around its
> usefulness.
Say I have a sequence seq and a string s, and I call s.join(seq).
Here's what it does:
s.join(seq) == seq[0] + s + seq[1] + s + seq[2] + s + ... + seq[-2] +
s + seq[-1]
So if you call 'abc'.join('ABC'), you get:
'ABC'[0] + 'abc' + 'ABC'[1] + 'abc' + 'ABC'[2]
which is:
'A' + 'abc' + 'B' + 'abc' + 'C'
Hope this helps.
--
John.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor