Message208306
Current behaviors 3.4b2
>>> itertools.repeat('a', -1)
repeat('a', 0)
>>> itertools.repeat('a', times=-1)
repeat('a') # forever
>>> itertools.repeat('a', times=-2)
repeat('a', -2)
My opinions (same as what Raymond says -- negative == 0)
The first line is correct in both behavior and representation.
The second line behavior (and corresponding repr) are wrong.
The third line repr is wrong but the behavior is like the first.
Guido's response on pydev, in context about having a signature that can be captured by C and Python. The main different is comment about adding None to the C signature in addition to the Python 'equivalent, which has 'times=None'.
"If I had complete freedom in redefining the spec I would treat
positional and keyword the same, interpret absent or None to mean
"forever" and explicit negative integers to mean the same as zero, and
make repr show a positional integer >= 0 if the repeat isn't None.
But I don't know if that's too much of a change."
I think the only thing different is comment about None. |
|
Date |
User |
Action |
Args |
2014-01-16 20:29:08 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, ezio.melotti, serhiy.storchaka, vajrasky |
2014-01-16 20:29:08 | terry.reedy | set | messageid: <1389904148.36.0.629755921567.issue19145@psf.upfronthosting.co.za> |
2014-01-16 20:29:08 | terry.reedy | link | issue19145 messages |
2014-01-16 20:29:08 | terry.reedy | create | |
|