I am writing a class
in Python3
and want a method to take a default self variable when no explicit value is given. For some reason this doesn't seem to work.
For example, the following code would produce a NameError: name 'self' is not defined
error for the 5th line.
class A:
def __init__(self, a):
self.a = a
def func(self, b=self.a):
pass
Is there a way around this if I want to make my function behave in the manner I specified?