class Stock:
... def __init__(self, ticker, price):
... self.ticker = ticker
... self.price = price
...
>>> apple = Stock('APPL', 100)
>>> apple.ceo='tim cook'
>>> google = Stock('GOOG', 10)
now if you compare dir(apple) and dir(google) the apple instance will have an extra attribute ceo.
however, isinstance(apple,Stock) and isinstance(google,Stock) are both True.
What is the intuition behind allowing objects with different attributes to both be instances of the same class? When do you use this, practically?
I would have thought that objects that are instances of the same class must have the same list of attributes.