How to make an empty generator?

Ben Finney ben+python at benfinney.id.au
Fri Feb 19 03:52:47 EST 2010


Arnaud Delobelle <arnodel at googlemail.com> writes:

> Ben Finney <ben+python at benfinney.id.au> writes:
> > Whether the OP needs to create a generator, or just any iterable
> > type, isn't clear.
>
> If it walks and quacks like a duck... Anyway it's not just an iterable
> object, it's an iterator.  I can't really imagine that there would be
> some code which would be happy with generators but not with iterators
> (as long as you can't send anything to them, which is always the case
> with an empty generator).

I can't imagine that someone would want to create a generator that's
always empty, but has some side-effect that is the *real* purpose for
using the generator.

Clearly, none of us should let our limited imaginations be the guide to
what people actually want to do.

-- 
 \          “Generally speaking, the errors in religion are dangerous; |
  `\    those in philosophy only ridiculous.” —David Hume, _A Treatise |
_o__)                                           of Human Nature_, 1739 |
Ben Finney



More information about the Python-list mailing list