[Python-ideas] Generators are iterators

Ethan Furman ethan at stoneleaf.us
Fri Dec 12 21:41:28 CET 2014


On 12/12/2014 12:06 PM, Alexander Belopolsky wrote:
> On Fri, Dec 12, 2014 at 2:28 PM, Ethan Furman wrote:
>> 
>> 3) write a class with __getitem__ that supports integer indexing
> 
> This gets you a custom iterable.  The corresponding iterator will be the buitin iterator type:
> 
>>>> class X:
> ...   __getitem__ = None
> ...
>>>> iter(X())
> <iterator object at 0x10b2a70b8>

Good catch, thanks!

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141212/d7f4719c/attachment.sig>


More information about the Python-ideas mailing list