Show how a Python class attribute is shared by every instance while an instance attribute is per-object.
A class attribute is written in the class body, so it belongs to the class itself and every instance shares it. An instance attribute is written as self.name, so it belongs to that one object only. The example below shows both kinds side by side.
class Dog:
species = 'canine' # a class attribute
count = 0 # a class attribute too
def __init__(self, name):
self.name = name # an instance attribute
Dog.count += 1
a = Dog('Rex')
b = Dog('Fido')
print(a.species, b.species) # canine canine
print(Dog.count) # 2, shared by every instance
# Setting it on one instance hides the class attribute for that instance only.
a.species = 'puppy'
print(a.species) # puppy
print(b.species) # canine, untouched
print(Dog.species) # canine, untouched
That output shows three different scopes in action. The name attribute lives on each instance separately, so a and b each have their own. The species attribute was found on the class through both instances, until you assigned to a.species. After that assignment, a has its own entry in its own dictionary, and that entry hides the class one for a only. The count attribute was increased on the class itself with Dog.count += 1, so it stayed shared, and that is the normal way to keep a shared counter.
The lookup rule is worth stating clearly, because it explains all of this. When you read an attribute, Python checks the instance first, and then the class. That is why an instance attribute hides a class attribute with the same name. It is also why deleting an instance attribute with del a.species makes the class attribute visible again, because the instance entry is gone and the lookup falls through to the class.