In this we are going to see a basic program of getattr method of constructor in Python Programming Language.
class Student:
def __init__(self, id, name, age):
self.id = id
self.name = name
self.age = age
s = Student(2, "Abhishek", 20)
print("Id: ", getattr(s, "id"))
print("Name: ", getattr(s, "name"))
print("age: ", getattr(s, "age"))
# Coded by Saahil
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP