[Python-3000] Automatically invoking str() in str.join()
Barry Warsaw
barry at python.org
Fri Apr 28 04:00:22 CEST 2006
On Thu, 2006-04-27 at 10:18 -0700, Alex Martelli wrote:
> > ''.join(seq) == join('', seq)
>
> I think I would prefer a signature of:
> join(seq, joiner='')
Except that I think it would be a mistake to have that and keep
the .join() method on strings because that would increase the confusion
in the argument order. For example, Guido pointed out a while ago that
a handy way to remember the argument order in re.search() and friends is
to think about pattern.search(string). That's a useful symmetry to
keep.
> Rationale: an emptystring joiner is the most frequent cases, but
> several others (space, newline, space-comma, ...) occur often enough
> to be worth allowing the joiner to be optionally specified.
If I look at the ones I write a lot it's emptystring, space, newline,
comma-space and the Unicode versions of them occasionally. There are
others, but those are probably the majority of them. I'm not sure what
that tells us, except that I don't think there's an obvious default.
You could probably argue for the emptystring just as well as for the
space.
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 309 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-3000/attachments/20060427/7249fa1f/attachment.pgp
More information about the Python-3000
mailing list