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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4