list to string
Alex Martelli
aleaxit at yahoo.com
Tue Feb 27 02:12:26 EST 2001
More information about the Python-list mailing list
Tue Feb 27 02:12:26 EST 2001
- Previous message (by thread): list to string
- Next message (by thread): list to string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Delaney, Timothy" <tdelaney at avaya.com> wrote in message news:mailman.983245987.15676.python-list at python.org... > Indeed. > > Personally, I think the join() string method is *really* bad. A method > should act on the object it is a part of. In this case, there is no > conceptual way that ''.join(['a', 'b', 'c']) could be considered to be > acting on '' - it is *using* ''. And, similarly, it's *using* ['a','b','c'] -- not "acting on" it. It's not a mutator. Not all methods of an object mutate it, and you clearly accept that, as you write: > OTOH, ''.length() is perfectly fine. It is obvious. Since join may use the joiner in a completely polymorphic way, but only uses the sequence through a sequence-iteration protocol, it's pragmatically _useful_ to have it be a method of the joiner object (as Python doesn't do multimethod-like dispatching). Usefulness seems to be a good indicator: if something offends your personal sense of purity, but is pragmatically good, then 'practicality beats purity' and it might be wise to reconsider your aesthetics:-). Alex
- Previous message (by thread): list to string
- Next message (by thread): list to string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list