# Interpret "for i in n" as "for i in range(n)" if n is an int

**URL:** <https://discuss.python.org/t/interpret-for-i-in-n-as-for-i-in-range-n-if-n-is-an-int/43457>\
**Category:** Ideas\
**Created:** [January 17, 2024, 8:46pm UTC](https://discuss.python.org/t/interpret-for-i-in-n-as-for-i-in-range-n-if-n-is-an-int/43457 "2024-01-17T20:46:03Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![ChrisBarker-NOAA](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/chrisbarker-noaa/32/17339_2.png) [@ChrisBarker-NOAA](https://discuss.python.org/u/ChrisBarker-NOAA)\
**Post date:** [January 21, 2024, 5:06pm UTC](https://discuss.python.org/t/interpret-for-i-in-n-as-for-i-in-range-n-if-n-is-an-int/43457/15 "2024-01-21T17:06:12Z")

</div>

We really do a need a FAITHBR (Frequently Asked Ideas that Have Been Rejected) somewhere …

But anyway, I’m not supportive of this idea, but I don’t think this logic holds:

Back in the day, Python was all about `Sequence`s – or maybe `Collection`s. But modern Python is more about Iterables.

`for _ in` is a way to iterate, that requires an iterable.

`in` by itself invokes ` __contains__ ` – and is about inclusion in a collection.

They use the same word, and there is often a parallel, but that doesn’t mean that there has to be – there are any number of iterables that are not containers. There is nothing surprising about that.

In fact, I wonder if the `range` object would be a container if it hadn’t evolved from the original `range()` that created a realized list. Does it get used that way often? (not in my code).

I still don’t think it’s a good idea for the other reasons posted in this thread, but the idea that anything iterable should be container is not compelling to me.

NOTE: _If_ an object is both an iterable and a container, then yes, there should be symmetry – e.g. what dicts do: using the keys for iteration and contains.

---

_[View the full topic](https://discuss.python.org/t/interpret-for-i-in-n-as-for-i-in-range-n-if-n-is-an-int/43457)._
