Terry J. Reedy added the comment: 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. ---------- nosy: +terry.reedy _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19145> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com