[Tutor] understanding join

Alan Gauld alan.gauld at btinternet.com
Thu Jul 31 07:53:11 CEST 2008


"Steve Poe" <steve.poe at gmail.com> wrote

> Your explanation is very help. It does make be wonder the usefulness
> of join with strings. Do you have a practical example/situation?

Its not really intended for strings but it needs to work that way to
be consistent because strings are just another type of collection
in Python and we want to treat collections (or sequences)
as consistently as possible.

But there are times when you want to separate the characters
of a string out for display and inserting a space or a comma
using join is convenient. It would be extremely rare to use

mystring.joing(mystring)

It is usually

myseparator.join(mysequence)

HTH
-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list