[Python-Dev] A Horrible Inconsistency (original) (raw)
Raymond Hettinger rhettinger at ewtllc.com
Thu May 25 23:17:35 CEST 2006
- Previous message: [Python-Dev] A Horrible Inconsistency
- Next message: [Python-Dev] A Horrible Inconsistency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Fredrik Lundh wrote:
>>> -1 * (1, 2, 3) () >>> -(1, 2, 3) Traceback (most recent call last): File "", line 1, in TypeError: bad operand type for unary -
We Really Need To Fix This!
The second one doesn't bug me. Unary minus on a sequence is meaningless.
The first is a bit odd. When using the * operator for sequence repetition, I don't expect it to have the same commutative property as multiplication. IOW, "seq * n" makes sense but "n * seq" is a bit weird. Also, I'm not clear on the rationale for transforming negative repetition counts to zero instead of raising an exception. OTOH, neither of these has EVER been an issue for me or anyone I know.
Raymond
- Previous message: [Python-Dev] A Horrible Inconsistency
- Next message: [Python-Dev] A Horrible Inconsistency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]