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

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to