On Thu, 10 Aug 2006 10:13:14 -0400
Jim Jewett <[EMAIL PROTECTED]> wrote:
#> >seq = seq + pad * (min_length- len(seq))
#>
#> Typically, if I need to pad a sequence to a minimum length, I really
#> need it to be a specific length. Having it already be too long is
#> likely to cause problems la
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.
With
Lawrence Oluyede wrote:
> seq * -5
> and to be honest I've never seen code like that because the semantics
> is somewhat senseless to me
To be honest, I would almost expect the negative to mean "count from
the end", so that it also reversed the sequence. It doesn't, but ...
it does make for a ha
> 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- l
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" shoul
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