help with calling a static method in a private class

Steven D'Aprano steve-REMOVE-THIS at cybersource.com.au
Thu Sep 16 00:29:39 EDT 2010


On Tue, 14 Sep 2010 16:38:50 +0200, Diez B. Roggisch wrote:


> And additionally, but simply not using staticmethods at all. It's a
> rather obscure feature of python - usually, classmethods are what is
> considered a static method in other languages. 

Are you sure about that? I know Java isn't necessarily "other languages", 
but my understanding is that static methods in Java are the same as 
static methods in Python -- they're essentially ordinary functions glued 
to a class, and they don't receive either the instance or the class as an 
argument.

http://leepoint.net/notes-java/flow/methods/50static-methods.html


(Aside: I don't know about others, but I find that article *incredibly* 
hard to read. E.g. 

    Static methods typically take all they data from 
    parameters and compute something from those parameters, 
    with no reference to variables.

What, parameters aren't variables? What about local variables? I know 
what they *mean*, but it causes a double-take every time I read it. And 
when they distinguish between *classes* and *objects*, that's another 
double-take, because of course in Python classes are objects.)


C# seems to be the same:

http://dotnetperls.com/static-method

as is C++ (I believe), except I'm too lazy to find a good reference.


-- 
Steven



More information about the Python-list mailing list