Methods vs. Functions (Re: [Python-Dev] A house upon the sand)

Greg Ewing greg@cosc.canterbury.ac.nz
Tue, 28 Nov 2000 13:24:07 +1300 (NZDT)


Guido said:

> It would be easy to propose join() as a built-in, and this looks
> attractive, if it weren't for the existence of os.path.join().

and

> join() is special: it is polymorphic in two arguments, and making
> it a method of the separator argument doesn't help.

How about an operator, then?

We already have % rather than a string.format or some such.
Presumably this is because Guido thought it was such a handy
thing that it should be instantly available at our fingertips.
I think a similar argument could be made for string.join, and
also its inverse string.split.

So, how about:

   x & s   == string.join(x, s)

   s1 | s2 == string.split(s1, s2)

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+