Can __iter__ be used as a classmethod?

Alex Martelli aleax at aleax.it
Wed Mar 19 07:21:22 EST 2003


Michele Simionato wrote:
   ...
>> > doesn't give any functionality.  I also think staticmethod is poorly
>> > named, since it does not produce a method, and it definitely doesn't
>> > do what a 'static method' does in Java or any other language I know
   ...
>> regarding your objection to the name.  Where's the "definitely doesn't
>> do" -- isn't a Python staticmethod just like e.g. a C++ static method?
   ...
>> What "definite" difference is totally escaping my notice...?
   ...
> A staticmethod is not a method, is a function, when called as in the

Nor did I say otherwise.  But I'm still totally puzzled by the
"definitely doesn't do what a 'static method' does in Java" and I
don't see how your answer addresses this.  What am I missing?

> this context) from regular methods(which now are functions). No difference
> at all in the normal usage, but big difference in metaprogramming

In Java there are no "functions" distinct from static method, so that
can't have anything to do with whatever the OP meant by "definitely
doesn't do".  In C++ there is no introspection / reflection, and a
static method IS also "a function" (you can take its address as a
pointer to function, NOT as a pointer to method).  So, I'm still
totally in the dark about what the "definitely doesn't do" refers
to -- *how* does a Python staticmethod differ from Java's or C++'s???


Alex





More information about the Python-list mailing list