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:
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
- Instance method in Python
- Class and Instance Attributes in Python
- Python | Ways to split a string in different ways
- Protected variable in Python
- Python | os.access() Method
- __name__ (A Special variable) in Python
- Python | Variable list slicing
- Python | Check if variable is tuple
- __file__ (A Special variable) in Python
- Python | Check if a variable is string
- Create and Access a Python Package
- Access Relation Databases with Python
- How to access a collection in MongoDB using Python?
- Python - Variable Operations Dictionary update
- Python Program to swap two numbers without using third variable
- Python | Set 6 (Command Line and Variable Arguments)
- Print Single and Multiple variable in Python
- Python | Accessing variable value from code scope
- Python | Using variable outside and inside the class and method
- Python - Access Parent Class Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.