Skip to content

Instantly share code, notes, and snippets.

@sebabouche
Created November 29, 2017 23:34
Show Gist options
  • Save sebabouche/914a3ddbbef5ffe2f584359801c0ec6a to your computer and use it in GitHub Desktop.
Save sebabouche/914a3ddbbef5ffe2f584359801c0ec6a to your computer and use it in GitHub Desktop.
These getattr and setattr can be very helpful!
class MyObject(object):
def __init__(self):
self.my_value = 0
my_obj = MyObject()
getattr(eval('my_obj'), 'my_value')
setattr(eval('my_obj'), 'my_value', 1)
my_obj.my_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment