[Python-Dev] A Horrible Inconsistency (original) (raw)
Tim Peters tim.peters at gmail.com
Thu May 25 23:25:07 CEST 2006
- Previous message: [Python-Dev] A Horrible Inconsistency
- Next message: [Python-Dev] A Horrible Inconsistency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Raymond Hettinger] ...
Also, I'm not clear on the rationale for transforming negative repetition counts to zero instead of raising an exception.
There are natural use cases. Here's one: you have a string and want to right-justify it to 80 columns with blanks if it's shorter than 80.
s = " " * (80 - len(s)) + s
does the right thing in all cases, because the blank repetition gracefully collapses to an empty string whenever len(s) >= 80. I've used that (and variants thereof) dozens of times. Then again, I don't believe I've ever used the "integer * sequence" form (i.e., with the integer on the left).
- Previous message: [Python-Dev] A Horrible Inconsistency
- Next message: [Python-Dev] A Horrible Inconsistency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]