Can __iter__ be used as a classmethod?

Alex Martelli aleax at aleax.it
Fri Mar 14 06:28:44 EST 2003


Phillip J. Eby wrote:
   ...
> I think it would be better to say that staticmethod is the one that
> 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
> of.

Nolo contendere regarding the functionality, but I'm totally puzzled
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?

class cpp
{
    static void greet() {
        std::cout << "Hello, world!\n";
    }
}

vs

class py:
    def greet(): print "Hello, world!"
    greet = staticmethod(greet)


What "definite" difference is totally escaping my notice...?


Alex





More information about the Python-list mailing list