Created
September 6, 2019 09:43
-
-
Save tdowgielewicz/2c81fbd83896044939447b5fdf037c4b 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
def autodict(*args): | |
""" | |
Creates dictonary from python variables where key is variable name and value is var value | |
:param args: python variables | |
:return: dictonary | |
""" | |
g = {k: v for k, v in globals().items() if not k.startswith('__')} | |
result = {} | |
for arg in args: | |
for k, v in g.items(): | |
try: | |
if v == arg: | |
result[k] = v | |
except ValueError: | |
continue | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment