I use Python 3 and I have small problem with kwargs. Is it possible to use instance attributes as a default argument value? I mean something like this:
class foo:
def __init__(self, a,b):
self.a = a
self.b = b
def setNewA(self, a=self.a):
print(a)
But I've got an error:
NameError: name 'self' is not defined
If I use class name I've got:
AttributeError: type object 'foo' has no attribute 'a'
I know that the other method is to use something like this:
def setNewA(self, a=None):
a = a or self.a
print(a)
But maybe there is some way to do it?