Last active
August 29, 2015 14:06
-
-
Save hymkor/d6547f379014f2b7938b to your computer and use it in GitHub Desktop.
Python で、超タイニー構造体 ref: http://qiita.com/zetamatta/items/69049d560a0bb949d78e
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
<MARKEDONE:~> | |
✏ ipy struct.py | |
10 20 <30> | |
<MARKEDONE:~> | |
✏ |
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
class Struct(object): | |
def __init__(self,**kargs): | |
for key,val in kargs.iteritems(): | |
setattr(self,key,val) | |
if __name__ == '__main__': | |
t = Struct(a=10,b=20,c=30) | |
t.c = "<30>" | |
print t.a, t.b, t.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment