Can __iter__ be used as a classmethod?

Giovanni Bajo noway at
Tue Mar 4 13:16:33 CET 2003

"Lulu of the Lotus-Eaters" <mertz at> ha scritto nel messaggio
news:mailman.1046733846.16852.python-list at
> "Bjorn Pettersen" <BPettersen at> wrote previously:
> |I would like to be able to traverse the content of a class (not an
> |instance) using a regular for loop: "for item in MyClass:...".

> If you want to add methods to a *class*, you create the class using a
> custom metaclass:

So, what is classmethod exactly doing? Looking at the example snippet, it
seems like it added a new method "items()" to the class.


More information about the Python-list mailing list