A Basic Python Class Example
October 2020
A Quick Look
This is my quick look reminder of how Python classes are structured.
# Class variables
=
=
# Constructor method with instance variables name and age
=
=
# Method with instance variable followers
# First object, set up instance variables of constructor method
=
# Print out instance variable name
# Print out class variable location
# Second object
=
# Print out instance variable name
# Use set_followers method and pass followers instance variable
# Print out class variable animal_type
Output:
Sammy
ocean
Stevie
This user has 77 followers
fish
end of line
Endnotes
I don't remember making this example. Feels like something I may have copy/pasted. That source has long since been forgotten if that waddBaseStyleSheetas the case.