[Python-3000] Python 3000 Status Update (Long!)
Steve Howell
showell30 at yahoo.com
Thu Jun 21 11:49:46 CEST 2007
--- Bill Janssen <janssen at parc.com> wrote:
> [...] It's more important to make things work
> consistently than to only
> have "one way". "sum" should concatenate strings.
>
"Sum" should sum stuff. You can't sum strings. It
makes no sense in English.
You can concatenate strings, or you can join them
using a connecting string. Since concatenating is
just a degenerate case of joining, it's hard to
justify a concat() builtin when you already have
''.join(), but I'd rather have a concat() builtin than
an insensible interpretation of sum().
Multiple additions (with "+") mean "sum" in
arithmetic, but you can't generalize that to strings
and text processing. The "+" operator for any two
strings is not about adding--it's about
joining/concatenating. So multiple applications of
"+" on strings aren't a sum. They're just a longer
join/concatenation.
Remember also that you can't have "+" operate on a
string/integer pair. It's just practicality that
Python uses the same punctuation for addition and
concatenation. In English it's sensible to have
punctuation for addition, so it has "+," but it needs
no punctuation for joining/concatenation, so Python
had to pick the closest match.
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/
More information about the Python-3000
mailing list