range() is not the best way to check range?

Simon Forman rogue_pedro at yahoo.com
Tue Jul 18 13:05:30 EDT 2006


Nick Craig-Wood wrote:
>
> Sets are pretty fast too, and have the advantage of flexibility in
> that you can put any numbers in you like
>

I know this is self-evident to most of the people reading this, but I
thought it worth pointing out that this is a great way to test
membership in range(lo, hi, step) without doing "the necessary
algebra".

i.e.  n in set(xrange(0, 10000, 23)) ...


Peace,
~Simon




More information about the Python-list mailing list