[Python-ideas] Pass a function as the argument "step" of range()
rosuav at gmail.com
Thu Jul 2 17:58:18 CEST 2015
On Fri, Jul 3, 2015 at 1:53 AM, Pierre Quentel <pierre.quentel at gmail.com> wrote:
> It's true, but testing that an integer is a range is very rare : the pattern
> "if X in range(Y)" is only found once in all the Python 3.4 standard library
> (in Lib/test/test_genexps.py), and "assert X in range(Y)" nowhere, whereas
> "for X in range(Y)" is everywhere.
That proves that testing for membership of "range literals" (if I may
call them that) is rare - which I would expect. What if the range
object is created in one place, and probed in another? Harder to find,
but possibly monkey-patching builtins.range to report on __contains__
and then running the Python test suite would show something up.
More information about the Python-ideas