Can __iter__ be used as a classmethod?

Samuele Pedroni pedronis at
Thu Mar 6 10:43:04 CET 2003

"Michele Simionato" <mis6 at> ha scritto nel messaggio
news:2259b0e2.0303050855.1eece801 at
> > This can be used as an argument to have them explicitely (you can
> > them anyway, so let's get them right once and for all) or to not have
> > (who need them can cook them up).
> In my view this is an argument against them.

I sympathize.

> > It is worth to notice that once you override one of them (like g in D
> > overriding g in C) it is impossible to call in a clean way the parent
> > version (C g) passing the derived class (D), which is what would happen
> > case of no overriding (if D would not define g, then D.g() would call g
in C
> > passing D), (so above C.g() obviously is calling g in C passing C).
> > call this their price".
> It seems to me that
> class D(C):
>     def g(cls):
>         print 'Dg',cls
>         C.g.im_func(cls)

Yes, but I would not count that as clean way.

More information about the Python-list mailing list