Last active
February 8, 2019 13:19
-
-
Save lordlycastle/6fa9b4c15fa6988eb93575f0232dd903 to your computer and use it in GitHub Desktop.
This file contains 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
# Example class | |
class Eg(object): | |
a = None | |
def __init__(self, a): | |
self.a = a | |
# look up dict to connect attribute to keys so I can get the relavent attr based on the key. | |
# issue is that it is easy to make mistake in string since there's no auto-complete and IDE checking. | |
# and obviously it's annoying to use. I | |
lookup_dict = {1: lambda eg: eg.a} | |
# Example usage implementation (not real!!!) | |
eg = Eg(10) | |
for k,v in lookup_dict.items(): | |
x = lookup_dict[k](eg) | |
#.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment