Can __iter__ be used as a classmethod?

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


"Michele Simionato" <mis6 at pitt.edu> ha scritto nel messaggio
news:2259b0e2.0303050855.1eece801 at posting.google.com...
> > This can be used as an argument to have them explicitely (you can
implement
> > them anyway, so let's get them right once and for all) or to not have
them
> > (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
in
> > 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).
"Let's
> > 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