Best way to access class-method into instance method

Viewed 4278
class Test(object):

    def __init__(self):
        pass

    def testmethod(self):
        # instance method
        self.task(10)      # type-1 access class method

        cls = self.__class__ 
        cls.task(20)        # type-2 access class method 

    @classmethod 
    def task(cls,val)
        print(val)

I have two way to access class method into instance method.

self.task(10)

or

cls = self.__class__
cls.task(20)

My question is which one is the best and why??

If both ways are not same, then which one I use in which condition?

1 Answers
Related