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.) | greg.ewing at canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4