[Python-3000] optimizing [x]range
Guido van Rossum
guido at python.org
Tue Jul 31 20:11:35 CEST 2007
On 7/31/07, skip at pobox.com <skip at pobox.com> wrote:
> Also, bringing it back more on-topic, what should the value of this
> expression be?
>
> 4 in range(0, 10, 3)
>
> That is, are we treating range() as a set or an interval? Maybe I missed
> earlier messages in this thread where this was discussed, but part of the
> discussion focused on this construct
>
> 0 <= 4 < 10
>
> where there was no option to provide a step size. Also, this particular
> notation screams out interval, not set, to me.
You missed it -- it should definitely be equivalent to
4 in list(range(0, 10, 3))
i.e.
4 in [0, 4, 8]
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list