Consider the following code:
class Car():
velocity = 1
class Chrysler(Car):
pass
class Ford(Car):
pass
print(f"Car:\t\t {Car.velocity}")
print(f"Chryler:\t {Chrysler.velocity}")
print(f"Ford:\t\t {Ford.velocity}")
print()
Car.velocity = 3
print(f"Car:\t\t {Car.velocity}")
print(f"Chryler:\t {Chrysler.velocity}")
print(f"Ford:\t\t {Ford.velocity}")
print()
Ford.velocity = 2
Car.velocity = 3
print(f"Car:\t\t {Car.velocity}")
print(f"Chryler:\t {Chrysler.velocity}")
print(f"Ford:\t\t {Ford.velocity}")
print()
Car.velocity = 4
print(f"Car:\t\t {Car.velocity}")
print(f"Chryler:\t {Chrysler.velocity}")
print(f"Ford:\t\t {Ford.velocity}")
The output yields:
Car: 1
Chryler: 1
Ford: 1
Car: 3
Chryler: 3
Ford: 3
Car: 3
Chryler: 3
Ford: 2
Car: 4
Chryler: 4
Ford: 2
First time I changed velocity to three, all inherited classes changed their static variable to three. However, if I change the velocity variable of Ford, I cannot change the velocity variable of Ford anymore just by changing the Car attribute.
Why is that the case? I would have expected Ford to be four as well in the end.