Re: Why tuple with one item is no tuple

From: Antoon Pardon (
Date: 03/30/05

Date: 30 Mar 2005 06:58:04 GMT

Op 2005-03-29, Ville Vainio schreef <>:
>>>>>> "Antoon" == Antoon Pardon <> writes:
> Antoon> Op 2005-03-27, Joal Heagney schreef <>:
> >> Antoon Pardon wrote:
> >> <snip>
> >>> So python choose a non-deterministic direction. To me (2,3) + (4,5)
> >>> equals (6,8). I don't dispute that having an operator to combine
> >>> (2,3) and (4,5) in (2,3,4,5) is usefull, but they should never have
> >>> used the "+" for that.
> >>
> >> ("alph", "bravo") + ("delta", "max") --> ("alphdelta", "bravomax")
> Antoon> No, that wouldn't be the result. You are still using "+"
> Antoon> for concatenation, even if only on strings. I say python
> Antoon> should have used something else for concatenation (string
> Antoon> concatenation included)
> To me, nothing is more natural than "ab" + "cd" == "abcd". Also [1,2]
> + [3,4] == [1,2,3,4]. "Dot product" is not really too useful in real
> world (non-mathematical) apps.

What is more natural, that you concatenate strings and lists or that
you use the "+" for it. Suppose python would have used '#" to express
concatenation so that "ab" # "cd" == "abcd". After using this for
sometime nothing would have been more natural than this.

Antoon Pardon

Relevant Pages

  • Re: From D
    ... string concatenation and allow numeric literals to implicitly concatenate? ... Did you miss the bit where Python ALREADY does this for strings? ... because two int tokens can be "concatenated" to make a single int token, ...
  • Re: Unexpected string behaviour: txt = this works
    ... So in Python it saves you to use + at the cost of possible bugs. ... I've used this feature in C and Python when I want to wrap strings ... with a set of parenthesis to make the concatenation explicit. ... It does do a minor optimization in Python and most C compilers. ...
  • Re: Why tuple with one item is no tuple
    ... Antoon> for concatenation, even if only on strings. ... world apps. ...
  • Re: string concatenation optimizations [from python-dev Summary]
    ... Essentially what I have in mind is a type that's a list of byte ... The value is defined as the concatenation of these arrays. ... > way to concatenate a bunch of strings. ...
  • Re: Resulting string from concatenation operator?
    ... that the operands must be either BIT or CHARACTER ... strings, and if not, the offending operand is converted. ... the result of the concatenation ... If the intermediate result of expression evaluation is a string it can be assigned to or passed to a variable or parameter of either fixed or varying length. ...