I have got a beginner problem. I would like to get an attribute from an instance. It work fine when i use getattr with 2 separeted arguments (object and the name of the attribute).
But I read that it's possible to just use one argument (like this : obj.attr). When I try it, I get an error : getattr expected at least 2 arguments, got 1. Why does it not work ?
class test :
def __init__ (self) :
self.name = "a"
inst = test()
print getattr (inst, "name")
print getattr (inst.name)
a
# Error: getattr expected at least 2 arguments, got 1
# Traceback (most recent call last):
# File "<maya console>", line 8, in <module>
# TypeError: getattr expected at least 2 arguments, got 1 #