Advertisements
Advertisements
Question
Give the statement to assign a value "Hello" to the attribute str of class Test and object T1.
Very Short Answer
Advertisements
Solution
setattr(T1, "str", "Hello")
To create/set str as a class attribute shared by all objects, use:
setattr(Test, "str", "Hello")
shaalaa.com
Is there an error in this question or solution?
