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):
...
It’s possible to change the default value this way:
Will mean that, if unset, the default will be 20.
E.g:
This utilises the fact that Python looks for class attributes if it doesn’t find an instance attribute.