Strange range
Chris Angelico
rosuav at gmail.com
Fri Apr 1 10:50:06 EDT 2016
On Sat, Apr 2, 2016 at 1:42 AM, Random832 <random832 at fastmail.com> wrote:
> On Fri, Apr 1, 2016, at 09:24, Chris Angelico wrote:
>> It is an iterable. It is not a factory, as that implies that you call
>> it.
>
> I do have an objection to this statement. It's perfectly reasonable to
> describe the factory pattern as applying to objects on which you call a
> method to return the new object you are interested in. In this sense,
> all collections are iterator factories.
Hmm. I suppose that would be reasonable, if you expect to call
range_object.__iter__() - but you shouldn't. You should call
iter(range_object), which, to my mind, means that *iter* is an
iterator factory.
Anyway, the word "iterable" accurately sums up the state: it's a thing
you can iterate over.
ChrisA
More information about the Python-list
mailing list