[Python-Dev] lament for the demise of unbound methods (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Fri Jul 5 12:26:06 CEST 2013


Am 04.07.13 18:42, schrieb Chris Withers:

Hi Guido,

I've bumped into this a couple of times. First time was when I wanted to know whether what I had was a classmethod, staticmethod or normal method here: https://github.com/Simplistix/testfixtures/blob/master/testfixtures/replace.py#L59

This resulted in having to trawl through dict here: https://github.com/Simplistix/testfixtures/blob/master/testfixtures/resolve.py#L17

You could use getattribute instead:

class A: ... @staticmethod ... def s(): ... pass ... @classmethod ... def c(cl): ... pass ... def r(self): ... pass ... A.getattribute(A,'s') <staticmethod object at 0x100937828> A.getattribute(A,'c') <classmethod object at 0x100937860> A.getattribute(A,'r') <function A.r at 0x100938378>

Regards, Martin



More information about the Python-Dev mailing list