Ian Kelly <ian.g.ke...@gmail.com>:

> On Wed, Apr 6, 2016 at 1:22 PM, Marko Rauhamaa <ma...@pacujo.net> wrote:
>> Why is a SimpleNamespace object not an iterator even though it
>> provides __iter__ and __next__?
>
> Because Python expects those methods to be defined in the class dict,
> not the instance dict.

The documentation does state: 

   these are used to allow user-defined classes to support iteration

although the rest of it only refers to objects.

It seems to me CPython is being a bit too picky here. Why should it care
if the method is a class method or an object method?

Anyway, that leaves the clever iterator trick out of No-Buzzword Python.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to