You create objects to hold state. If you had something like:
class Wallet(object):
balance = 0
It wouldn't make sense to share the same balance between multiple instances of the class. You'd want to create a new instance of Wallet
for each bit of money you're trying to track.
Because you'd use it by doing something like:
fred.wallet = Wallet
jim.wallet = Wallet # same object!
So now when Fred spends money
fred.wallet.balance -= 3.50
Jim spends that money too.
>>> print(jim.wallet.balance)
3.50
Instead you'd want to create INSTANCES of the class Wallet
and give each one its own state
class Wallet(object):
def __init__(self, balance=0):
# __init__ is called when you instantiate the class
self.balance = balance
fred.wallet = Wallet()
jim.wallet = Wallet()
Now when Fred spends money:
fred.wallet.balance -= 3.50
Jim won't be affected because his Wallet
object is a different instance
>>> print(jim.wallet.balance)
0