Skip to content

Instantly share code, notes, and snippets.

Created November 3, 2015 21:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
class Foo(object):
def __init__(self):
self.history = {"var1": [], "var2": [], "var3": [], "var4": []}
def update(self, to_update):
for k, v in self.history.iteritems():
if k == to_update:
if __name__ == "__main__":
foo = Foo()
vars = ["var1", "var2", "var1", "var4"]
print foo.history
for var in vars:
print foo.history
Copy link

roryk commented Nov 3, 2015

rory@clotho:~$ python
{'var4': [], 'var1': [], 'var3': [], 'var2': []}
{'var4': [], 'var1': [], 'var3': [], 'var2': []}
{'var4': [nan], 'var1': [1], 'var3': [nan], 'var2': [nan]}
{'var4': [nan, nan], 'var1': [1, nan], 'var3': [nan, nan], 'var2': [nan, 1]}
{'var4': [nan, nan, nan], 'var1': [1, nan, 1], 'var3': [nan, nan, nan], 'var2': [nan, 1, nan]}
{'var4': [nan, nan, nan, 1], 'var1': [1, nan, 1, nan], 'var3': [nan, nan, nan, nan], 'var2': [nan, 1, nan, nan]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment