Like we have in Java Beans util where you pass object and the property name it gives you the value do we have anything similar in python:
def attr(obj, attr)
return obj.attr
Like we have in Java Beans util where you pass object and the property name it gives you the value do we have anything similar in python:
def attr(obj, attr)
return obj.attr
You can use getattr for this purpose. From the built-in function documentation:
For example,
getattr(x, 'foobar')is equivalent tox.foobar.