[Python-Dev] method decorators (PEP 318) (original) (raw)

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Mar 29 01:26:13 EST 2004


Josiah Carlson <jcarlson at uci.edu>:

> I'm not sure I understand. Why not make them module-level functions?

Namespaces my friend, namespaces (I don't know if other people use this, but I have on occasion).

My point was, that in any likely use I can think of for staticmethods, it wouldn't do any harm to use a classmethod instead.

def makeallstatic(cls): for i,j in cls.dict.iteritems(): if isinstance(j, instancemethod) cls.dict[i] = staticmethod(j)

You'd still be able to do that, just as you'd still be able to use the old method of creating a staticmethod. There just wouldn't be any special syntax just for staticmethods analogous to the one I suggested for classmethods.

Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+



More information about the Python-Dev mailing list