String.join revisited (URGENT for 1.6)
Eric Jacobs
none at none
Sun May 28 21:41:29 EDT 2000
In article <28052000.5 at sanctum.jae.ddns.org>,
"Juergen A. Erhard"
<jae at ilk.de> wrote:
> Simple: many folks have said in the past days/weeks (since this
> "string".join(list) came up) that they'd be a lot more comfortable
> with s.th. like
>
> [list].join(separator)
>
> But others have contested this saying it would put string knowledge into
> lists (or rather sequences... which do not exactly exist[1])
Doesn't seem like it would have to. Just imagine a method in the sequence
"class" that said:
def join(self, separator):
result = self[0]
for x in self[1:]:
result = result + separator + x
return result
No new operators are necessary, unless you want join to do something
completely different... in which case define a new method and stop
trying to get join to do everything.
More information about the Python-list
mailing list