I've found the following open source code in Python:
class Wait:
timeout = 9
def __init__(self, timeout=None):
if timeout is not None:
self.timeout = timeout
...
I'm trying to understand if there are advantages of the code above vs using default argument's value:
class Wait:
def __init__(self, timeout=9):
...
self.timeout = 9, in the second example construct, you're setting a class variable/attribute.self.x = ..., you are setting an instance attribute.Wait.timeoutthrows anattributeError. In the first, it does not.