[Python-3000] Python 3000 Status Update (Long!)
Steve Howell
showell30 at yahoo.com
Thu Jun 21 19:12:30 CEST 2007
--- Bill Janssen <janssen at parc.com> wrote:
> > 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.
>
> Hmmm. Your argument would be more pursuasive if you
> couldn't do this
> in Python:
>
> >>> a = "abc" + "def" + "ghi" + "jkl"
> >>> a
> 'abcdefghijkl'
> >>>
>
> The real problem with "sum", I think, is that the
> parameter list is
> ill-conceived (perhaps because it was added before
> variable length
> parameter lists were?). It should be
>
> sum(*operands)
>
> not
>
> sum(operands, initialvalue=?)
>
> It should amount to "map(+, operands)".
>
I think you were missing my point, which is that sum
doesn't and shouldn't necessarily have the same
semantics as map(+).
"Sum," in both Python and common English usage, is a
generalization of arithmetic addition, but it's not a
generalization of applying operators that happen to be
spelled "+."
There's no natural English punctuation for
concatenation, and Python's choice of "+" could be
called mostly arbitrary (although it's consistent with
a few other programming languages.) The following
operators can mean concatenation in various
programming languages:
+
.
&
||
Oddly, in English a common way to concatenate words is
with the "-" character. It means a hyphen in English,
and it's use to create multi-word-thingies, but the
operator itself is also a subtraction operator. So
you could speciously argue that when you concatenate
words in English, you're doing a difference, but under
your proposed Python, you'd be doing a sum.
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
More information about the Python-3000
mailing list