empty lists vs empty generators

Jeremy Bowers jerf at jerf.org
Wed May 4 16:59:00 EDT 2005


On Wed, 04 May 2005 20:33:31 +0000, Leif K-Brooks wrote:
> With the EmptyGeneratorDetector class as you defined it, lists will fail:
> 
>  >>> EmptyGeneratorDetector([])
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
>    File "<stdin>", line 15, in __init__
> AttributeError: 'list' object has no attribute 'next'
> 
> Of course, the class is labeled as an empty generator detector, not an
> empty iterable detector, so it's doing what it says it will, but a little
> bit of extra generalism can't hurt.

OK, thanks, now I see what you mean. I was worried that you might be
referring to an iterator type that returned something other than itself
when you called iter on it, which I thought wasn't legal.



More information about the Python-list mailing list