Lawrence Oluyede wrote:
> I've never seen bugs determined by operations such as:
> 
> "foobar" * -1
> 
> and to be honest I've never seen code like that because the semantics
> is somewhat senseless to me but I think the behavior of the expression
> evaluation of "Sequence * negative integer" should be changed from:
> 
>>>> "foobar" * -1
> ''
>>>> ["foobar"] * -1
> []
>>>> ("foobar") * -1
> ''
> 
> to something throwing an exception like when you try to multiplicate
> the sequence by a floating point number:
> 
>>>> "foobar" * 1.0
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: can't multiply sequence by non-int
> 
> It's not a big deal to me but maybe this can be addressed in the
> python3000 branch
> 

The "negative coerced to 0" behaviour is to make it easy to do things like 
padding a sequence to a minimum length:

   seq = seq + pad * (min_length- len(seq))

Without the current behaviour, all such operations would need to be rewritten 
as:

   seq = seq + pad * max((min_length- len(seq)), 0)

Gratuitous breakage that leads to a more verbose result gets a solid -1 from me 
:)

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to