We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I just realized how you got confused, when I realized the tutorial is explained in Java. In Java, you can reference instance variables without using this or self as a shortcut. Python does not have this. Java is OO only, so they can get away with that, but Python is a procedural language with OO added on, so it supports global variables and more advanced scoping, so you always have to reference instance variables explicitly as self.age as just age will reference something completely differently, but only in Python, not Java.
Day 4: Class vs. Instance
You are viewing a single comment's thread. Return to all comments →
I just realized how you got confused, when I realized the tutorial is explained in Java. In Java, you can reference instance variables without using
this
orself
as a shortcut. Python does not have this. Java is OO only, so they can get away with that, but Python is a procedural language with OO added on, so it supports global variables and more advanced scoping, so you always have to reference instance variables explicitly asself.age
as justage
will reference something completely differently, but only in Python, not Java.