[Python-ideas] Consider making enumerate a sequence if its argument is a sequence

Chris Angelico rosuav at gmail.com
Thu Oct 1 07:30:14 CEST 2015


On Thu, Oct 1, 2015 at 11:31 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> Personally, I don't like it, but using "n in range(a, b+1)" for testing
> whether integer n falls within a particular range seems to be popular. I
> don't know why they don't just write a <= n <= b, but it seems to be a
> popular idiom for some weird reason.

You could have a third arg to range, in which case it also adds in a
modulo check.

ChrisA


More information about the Python-ideas mailing list