How can I use dot notation to access a member variable?


#1

Question

How can I use dot notation to access a member variable?

Answer

If you’re trying to access a member variable, you do not need parentheses at the end, otherwise it looks for a method with the name you typed.
To access a member variable, we simply type the name of the variable after a dot connected to the object we want to access, like this:
print my_object.property_name


FAQ: Learn Python - Classes - Calling class member variables