I have a class A with a member function a and a parameter p with a default value. I want this default value to be the member variable of the class.
class A:
def a(self, p = self.b):
print p
However it crashed with the information:
<ipython-input-2-a0639d7525d3> in A()
1 class A:
----> 2 def a(self, p = self.b):
3 print p
4
NameError: name 'self' is not defined
I want to know whether I can pass a member variable as a default parameter to the member function?