Strange range

Ian Kelly ian.g.kelly at gmail.com
Fri Apr 1 10:52:27 EDT 2016


On Fri, Apr 1, 2016 at 8: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.

I think the problem with that is that it implies something about the
purpose of the object. Usually when we talk about the factory pattern,
we're talking about an object that creates instances of something and
does nothing else. So in that sense it's misleading to refer to dict
or list or even range objects as "iterator factories", because they
also do a lot of other things that are equally if not more important.



More information about the Python-list mailing list