Unification of Methods and Functions

Greg Ewing greg at cosc.canterbury.ac.nz
Thu May 6 23:48:29 EDT 2004


David MacQuigg wrote:
> Wow,
> you mean staticmethods aren't fundamentally necessary, just a bandaid
> to make up for Python's deficiencies?

In Python, staticmethods are not fundamentally necessary,
full stop. We keep trying to tell you that, but it seems
you have your fingers in your ears.

The only possible reason to use a staticmethod in Python
is if you want it to be in the class's namespace. But that's
not a need, it's only a want. There are other ways of
resolving namespace issues.

Python didn't even *have* staticmethods until very
recently, and programmers got on just fine without them.
The only reason they were added is that the new descriptor
mechanism made it easy to do so.

In the past, every now and then someone (coming from C++)
would ask how to create a static method in Python. They were
added simply to appease these people. Regular Python programmers
just carried on as usual and ignored staticmethods.

Even now, staticmethods could be removed from the language
entirely and very little would be affected.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list