Message 208306 - Python tracker (original) (raw)

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.