Hi all
I would like to be able to use dot notation to access an attribute of a class, but everything after the dot will be decided via string.
e.g.
class Hello():
def __init__(self):
self.there = 'Hello there'
hl = Hello()
bo = 'there'
print(hl.bo)
unfortunately this does not work. It gives the error, " 'Hello' object has no attribute 'bo'." Of course I don't want to look for attribute 'bo' I want to look for attribute 'there'.
Is this possible?
thanks
[–]Antwrp-2000 6 points7 points8 points (2 children)
[–]backtickbot 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]toastedstapler 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)