Guido van Rossum wrote:

> str.join() is an interesting case...

 > Making it a
> string method is arguably the right thing to do, since this operation
> only makes sense for strings. 

 > The type of such a polymorphic function is easily specified:
> join(sequence[T], T) -> T, where T is a string-ish type.

I'd say it makes sense for any type that supports
concatenation (maybe that's what you mean by "string-ish"?)

This looks like a case where the xxx()/__xxx__() pattern
could be of benefit. Suppose there were a function

   def join(seq, sep):
     if hasattr(sep, '__join__'):
       return sep.__join__(seq)
     else:
       # generic implementation

Then you could get nice fast type-specific implementations
for strings, bytes, etc., without being limited to those
types.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,          | Carpe post meridiam!                 |
Christchurch, New Zealand          | (I'm not a morning person.)          |
[EMAIL PROTECTED]          +--------------------------------------+
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to