I'm trying to write something like:
class MyClass(object):
@staticmethod
def test(x, y, z=None):
if not z:
z = external_function(MyClass)
Is it possible in python to rewrite it to something like:
class MyClass(object):
@staticmethod
def test(x, y, z=external_function(MyClass)):
pass
(The second code does not work as it is referencing MyClass which is not defined at this point)
selfas their first variable. 99% of the time, you're not passing the class to an external function, you're passing the instance variable (or object),self, to the external function. What you're doing with the class as a whole, seems incorrect. Are you trying to write a@classfunction? Or are you trying to manipulate an object of the class?@staticmethod.testa classmethod, which takesclsas the first parameter, then use that in your call toexternal_function.