[Tutor] join - was best way to tokenize [was script too slow]

Jeff Shannon jeff@ccvcorp.com
Wed Feb 26 16:42:03 2003


Michael Janssen wrote:

>---> instead of using a method as the method of the string you are working
>on you make an "auxiliary" string and give your "working-string" as a
>parameter. There might be good reasons for this, but that's not
>python-like syntax as readable as natural language.
>

Except that most often when using join(), you're not using a string as 
the "other" argument -- any sequence can be used and it's *much* more 
common to use a list.  This "working string" you talk about usually 
doesn't exist, as such.  At the time that string methods were being 
introduced, there was a camp who argued that (sequence).join(string) was 
a more "intuitive" way to spell this, but the problem is that then you 
need to have a join() method on *every* possible type of sequence... 
which may well include user-defined types, where it's impossible to 
enforce a join() method.  It was decided that having the current 
spelling was much more sensible, since it's easy for a string to join 
*any* sort of sequence, and nothing depends on the type of sequence 
being used.  If you read it as "use this string to join together the 
elements of this sequence", it's not at all bad readability-wise, either.

Jeff Shannon
Technician/Programmer
Credit International