getattr(A, command)(newSet)
class Person:
age = 23
name = "Adam"
person = Person()
print('The age is:', getattr(person, "age"))
print('The age is:', person.age)
getattr(A, command)(newSet)
class Person:
age = 23
name = "Adam"
person = Person()
print('The age is:', getattr(person, "age"))
print('The age is:', person.age)
python getattr function
class Student:
name = 'John'
age = 24
student = Student()
print('Student name: ', getattr(student, 'name'))
print('Student age: ', getattr(student, 'age'))
# Output
# Student name: John
# Student age: 24
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us