list to string
tdelaney at avaya.com
Tue Feb 27 04:52:34 CET 2001
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* ''.
However, join() should also not be a method of sequences in general IMO
(although there is more reason to). Instead, there should *only* be
string.join() - it is an external function which acts on one thing with the
help of another. Actually, there should really be sequence.join(), and
string.join() should be deprecated ...
The object being acted upon should *always* be listed first, whether it be
as the target for a bound method, or as the first parameter of a function.
''.join() is a glaring, non-obvious inconsistency that I will not use.
OTOH, ''.length() is perfectly fine. It is obvious.
+61 2 9352 9079
> -----Original Message-----
> From: Erno Kuusela [mailto:erno-news at erno.iki.fi]
> Sent: Tuesday, 27 February 2001 2:25 PM
> To: python-list at python.org
> Subject: Re: list to string
> In article <3a9b14c9.33237453 at news-server.austin.rr.com>,
> jgraves3 at austin.rr.com (jay graves) writes:
> | Some people don't like using the string methods in this way and they
> | might write: (at least until the string module goes away.)
> | import string
> | string.join(result,'')
> the string module isn't going away, it has lots of stuff that
> is not available as methods of strings.
> -- erno
More information about the Python-list