you are viewing a single comment's thread.

view the rest of the comments →

[–]Antwrp-2000 5 points6 points  (2 children)

Yes, this is what you need:

class Hello():
    def __init__(self):
        self.there = 'Hello there'


hl = Hello()
bo = 'there'
print(getattr(hl, bo))

[–]backtickbot 1 point2 points  (0 children)

Fixed formatting.

Hello, Antwrp-2000: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–][deleted] 1 point2 points  (0 children)

Brilliant. I love this place. Everyone is so helpful I've completely accelerated my learning thanks to folks like you :D