Can __iter__ be used as a classmethod?
Alex Martelli
aleax at aleax.it
Thu Mar 6 06:06:13 EST 2003
Michele Simionato wrote:
...
>> 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.
Pretty weak argument too -- like saying we don't need the built-in
abs because everybody needing it could code it up for themselves!-)
>>>> c=classmethod(f)
>>>> c.__get__(None)
> <bound method type.f of <type 'NoneType'>>
>
> In a sense, staticmethods are really functions, whereas classmethods are
> really methods. However, I wonder if there is a direct way to extract f
> from the classmethod ?
Sure, c.im_func is f. That's how methods work.
Alex
More information about the Python-list
mailing list