[Python-Dev] defaultdict and on_missing() (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 2 05🔞38 CET 2006
- Previous message: [Python-Dev] defaultdict and on_missing()
- Next message: [Python-Dev] defaultdict and on_missing()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 +--------------------------------------+
- Previous message: [Python-Dev] defaultdict and on_missing()
- Next message: [Python-Dev] defaultdict and on_missing()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]