Skip to content

Instantly share code, notes, and snippets.

@kranfix
Created March 29, 2020 18:28
Show Gist options
  • Save kranfix/f3b8cf554b25b6c6f7e9524aec6bf0af to your computer and use it in GitHub Desktop.
Save kranfix/f3b8cf554b25b6c6f7e9524aec6bf0af to your computer and use it in GitHub Desktop.
Example for exploring reflexion in python
class Foo():
def __init__(self):
self.bar = "Hello!"
foo = Foo()
print(foo.__dir__())
print("-----------------------")
print(foo.bar)
print(getattr(foo,"bar"))
print("-----------------------")
setattr(foo,"bar","Good bye!")
print(foo.bar)
print(getattr(foo,"bar"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment