How to set the value of the specific attribute of specific object in Python

1 Answer

0 votes
class Worker:
    name = "Fox"
    age = 52
    profession = "Programmer"
    language = "python"
    

print(getattr(Worker, 'language'))

setattr(Worker, 'language', "c++")

print(getattr(Worker, 'language'))


'''
run:

python
c++

'''

 



answered Dec 15, 2018 by avibootz

Related questions

...