Can __iter__ be used as a classmethod?
noway at sorry.com
Tue Mar 4 13:16:33 CET 2003
"Lulu of the Lotus-Eaters" <mertz at gnosis.cx> ha scritto nel messaggio
news:mailman.1046733846.16852.python-list at python.org...
> "Bjorn Pettersen" <BPettersen at NAREX.com> 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