This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients ezio.melotti, rhettinger, serhiy.storchaka, terry.reedy, vajrasky
Date 2014-01-16.20:29:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1389904148.36.0.629755921567.issue19145@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-01-16 20:29:08terry.reedysetrecipients: + terry.reedy, rhettinger, ezio.melotti, serhiy.storchaka, vajrasky
2014-01-16 20:29:08terry.reedysetmessageid: <1389904148.36.0.629755921567.issue19145@psf.upfronthosting.co.za>
2014-01-16 20:29:08terry.reedylinkissue19145 messages
2014-01-16 20:29:08terry.reedycreate