1

I use static method in Python, like this:

class A(object):

    @staticmethod
    def sfun():
        print "this is statice method"

class AA(A):

    @staticmethod
    def sfun():
        print "this is statice method"

And I want to get type of class (A or AA) in sfun. How can I do it?

1 Answer 1

5

You can't. But if you use classmethod instead then the class will be passed as the first argument to the method.

class A(object):
  @classmethod
  def cfun(cls):
    print 'I am in %r' % (cls,)

class AA(A):
  pass
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.