Could somebody explain me difference between these two pieces of code? I know that in the second case the arguments can be passed while instansiating the object but my problem was that when I used the 2 option, then the ledger list contained all objects that I have created. With the first one list is unique for the object as expected.
-
def __init__(self, category): self.category = category self.ledger = [] self.balance = 0.0
-
def __init__(self, category, ledger = [], balance = 0.0): # Assign self to object self.category = category self.ledger = ledger self.balance = balance