Question
Why use member variables over instance variables?
Answer
Member variables are those that you want to be the same across all objects of a class. In our Animal
example, all animals should be alive, so we set is_alive = True
as a member variable.
However, things that might differ from animal to animal are their name
and age
! So for those things that are not the same across the board, we create instance variables.