Skip to content

Instantly share code, notes, and snippets.

@binarymatt
Last active September 24, 2015 14:06
Show Gist options
  • Save binarymatt/208f81be12842ef48bf6 to your computer and use it in GitHub Desktop.
Save binarymatt/208f81be12842ef48bf6 to your computer and use it in GitHub Desktop.
import collections
class DummyDict(collections.UserDict):
def __getattr__(self, attr):
return self['temp'+attr]
def __setattr__(self, attr, value):
self['temp"+attr] = value
d = DummyDict()
for my_data in dates:
setattr(d, my_data, len(my_data)
d.mydata
dates = ['01152015','02192015','03152014','05302015','06052015','07212015','08152015']
d = type('Dummy', (),{})()
for my_data in dates:
setattr(d, 'temp'+my_data, len(my_data))
print dir(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment