Thomas Wouters wrote:
> It doesn't matter. Either case is confusing, one way or another, as Tim
> has already argued. Changing it would be a big mistake. If you want me
> to come with more comprehensive arguments (other than what Tim already
> covered), please come with more comprehensive arguments *for* the
> change, too.
What if the join() builtin had a similar signature to min() & max(), and the
separator was a keyword only argument? Something like:
def join(*args, **kwds):
# Need a mutable seq to handle type conversions
if len(args) == 1:
seq = list(args[0]) # Single argument handled as iterator
else:
seq = list(args) # Multiple arguments also accepted
# Check for a custom separator (keyword argument only)
sep = kwds.pop('sep', '')
assert not kwds
assert isinstance(sep, basestring)
# Check if we want unicode or 8-bit strings
sep_is_unicode = isinstance(sep, unicode)
use_unicode = sep_is_unicode or any(isinstance(x, unicode) for x in seq)
# Convert all items to desired type
if use_unicode:
desired = unicode
if not sep_is_unicode:
sep = unicode(sep)
else:
desired = str
for i, item in enumerate(seq):
if not isinstance(item, desired):
seq[i] = desired(item)
# Perform the join operation
return sep.join(seq)
(as with min() and max(), a single argument which is a non-sequence doesn't
make sense, as it would simply mean that join(x) == x).
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com