Created
March 29, 2020 18:28
-
-
Save kranfix/f3b8cf554b25b6c6f7e9524aec6bf0af to your computer and use it in GitHub Desktop.
Example for exploring reflexion in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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