➜

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.

作者 terry.reedy
收信人 ezio.melotti, rhettinger, serhiy.storchaka, terry.reedy, vajrasky
日期 2014-01-16.20:29:08
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1389904148.36.0.629755921567.issue19145@psf.upfronthosting.co.za>
In-reply-to
内容
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.
历史
日期 用户 动作 参数
2014-01-16 20:29:08terry.reedy修改recipients: + terry.reedy, rhettinger, ezio.melotti, serhiy.storchaka, vajrasky
2014-01-16 20:29:08terry.reedy修改messageid: <1389904148.36.0.629755921567.issue19145@psf.upfronthosting.co.za>
2014-01-16 20:29:08terry.reedy链接issue19145 messages
2014-01-16 20:29:08terry.reedy创建