Message208848
This problem been independently rediscovered by people converting
code to Argument Clinic. A Python signature can't express these
semantics, where a parameter behaves differently depending on
whether it's passed in by keyword or by reference. So Argument
Clinic can't either. I think it would be best if itertools.repeat
behaved like a pure Python function--that is, that it behaved
the same whether "times" was passed in by position or by keyword.
What's I find curious: the documentation is wildly out of sync with the implementation. It says:
itertools.repeat(object[, times])
....
def repeat(object, times=None):
....
http://docs.python.org/3.4/library/itertools.html#itertools.repeat
But repeat() doesn't support passing in None for the times parameter,
if indeed it ever has.
I see two possible choices here.
1) Honor the existing behavior. Change the signature to simply
def repeat(object, times=-1):
and document it that way.
2) Honor the documentation. Change the implementation to
def repeat(object, times=None):
This change could break code. So we'd have to go through a
deprecation cycle. Breaking "times=-1" without a deprecation
cycle is simply not viable at this point.
I could live with either. |
|
Date |
User |
Action |
Args |
2014-01-22 20:36:02 | larry | set | recipients:
+ larry, rhettinger, terry.reedy, ezio.melotti, serhiy.storchaka, vajrasky |
2014-01-22 20:36:02 | larry | set | messageid: <1390422962.57.0.34893926064.issue19145@psf.upfronthosting.co.za> |
2014-01-22 20:36:02 | larry | link | issue19145 messages |
2014-01-22 20:36:01 | larry | create | |
|