2006/5/25, Fredrik Lundh <[EMAIL PROTECTED]>:

>  >>> -1 * (1, 2, 3)
> ()
>  >>> -(1, 2, 3)
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> TypeError: bad operand type for unary -
>
> We Really Need To Fix This!

I don't see here an inconsistency. The operator "*" is not a
multiplier as in math, it's more a "repeater", so math multiplier
attributes don't apply here.

There's no concept like "negative tuple" or "positive tuple", so the
second example is clearly an error.

Regarding the first line, in the docs expresely says "Values of n less
than 0 are treated as 0".

I think that we can do one of the following, when we found "-1 * (1, 2, 3)":

- Treat -1 as 0 and return an empty tuple (actual behavior).
- Treat the negative as a reverser, so we get back (3, 2, 1).
- Raise an error.

Personally, +0 on the third.

Regards,

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to