Pattern: Member accessed before definition
Issue: -
If class member is used before definition, a runtime error will be raised. Define it first to resolve this issue.
Example of incorrect code:
class Test:
def __init__(self):
print(self.name) # name is not yet defined
self.name = "test"
Example of correct code:
class Test:
def __init__(self):
self.name = "test"
print(self.name)