Different ways to access Instance Variable in Python
Instance attributes are those attributes that are not shared by objects. Every object has its own copy of the instance attribute i.e. for every object, instance attribute is different.
There are two ways to access the instance variable of class:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Example 1: Using Self and object reference
hello my name is: HARRY my roll number is: 1001 HARRY
Example 2: Using getattr()
Harsh True 152