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

Nick Coghlan ncoghlan at gmail.com
Thu Aug 10 16:33:27 CEST 2006

Jim Jewett wrote:
> I would write it as
> # Create a record-size pad outside the loop
> pad = " "*length
> ...
>    seq = (seq+pad)[:length]

I'd generally do padding to a fixed length that way as well, but any code 
relying on the current 'clip to 0' behaviour would break if this changed. 
Without a really compelling reason to change it, it's hard to justify any 
breakage at all (even if there may be better ways of doing things).

While I take your point about the comparison to __index__, the difference is 
that clipping sequence repetition to 0 has been the expected behaviour for 
many releases, whereas in the __index__ overflow case the expected behaviour 
was for the code to raise an exception.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-3000 mailing list