Last active
September 24, 2015 14:06
-
-
Save binarymatt/208f81be12842ef48bf6 to your computer and use it in GitHub Desktop.
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
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 |
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
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