[Python-3000] Changing behavior of sequence multiplication by negative integer

Lawrence Oluyede l.oluyede at gmail.com
Thu Aug 10 14:03:28 CEST 2006


> 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 :)

That sound a -1 to me too. Thanks for the explanation. I was sure
there was one for that kind of behavior.


-- 
Lawrence
http://www.oluyede.org/blog


More information about the Python-3000 mailing list