Can __iter__ be used as a classmethod?
Bjorn Pettersen
BPettersen at NAREX.com
Tue Mar 4 04:47:18 EST 2003
More information about the Python-list mailing list
Tue Mar 4 04:47:18 EST 2003
- Previous message (by thread): Can __iter__ be used as a classmethod?
- Next message (by thread): Can __iter__ be used as a classmethod?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> From: Lulu of the Lotus-Eaters [mailto:mertz at gnosis.cx] > > "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: Thank you very much! Could you also explain why <wink>? (e.g. why can I make items() a classmethod but not __iter__, and how does __metaclass__.__iter__ get called from iter(ClassIter)? -- it doesn't show up when using dir()...) Just doing my first meta class project since Smalltalk in the early 90's... -- bjorn
- Previous message (by thread): Can __iter__ be used as a classmethod?
- Next message (by thread): Can __iter__ be used as a classmethod?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list