static vs variable field in a class
Do I interpret the follwoing observation correctly:
class Car(): name = "VW" def __init__(self,name): self.name = name givenName = name car = Car("Tesla") print(car.givenName) print(car.name)
Output:
VW Tesla
If a variable of a class is outside of the init statement, than it is static and I can’t override it in the init statement, instead there is an other, mutable field of the class with the same name.
Futhermore, if I would not declare givenName, then I would not be able to access the static field name of the class?
Thanks for helping 🙂