1

Checking to see if m.im_self is the class works some of the time but doesn't seem to be 100% reliable (ex. if you use multiple decorators on a method.)

4
  • Please provide code examples of working/non-working scenarios. Commented Nov 6, 2009 at 13:17
  • 1
    What's wrong with reading the source? Commented Nov 6, 2009 at 13:22
  • 2
    Related: stackoverflow.com/questions/1259963/… Commented Nov 6, 2009 at 13:34
  • 1
    Provocative answer, as you didn't specify what you want to achieve: Why do you even care? If you can invoke it - you're fine. If you can't - well, that can happen regardless whether it's a classmethod, staticmethod or instance method. Commented Nov 6, 2009 at 13:34

1 Answer 1

2

If it's a bound method on the class then it's a classmethod.

from inspect import ismethod, isclass
def isclassmethod( m ):
 return ismethod(m) and isclass(m.__self__)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.