Created
October 26, 2014 15:52
-
-
Save selfsame/c330cffeea1e0818a08d to your computer and use it in GitHub Desktop.
comp/entitity
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
1 #!/usr/bin/env python | |
2 | |
3 def string_to_comp(s): | |
4 try: | |
5 return globals()[s] | |
6 except: | |
7 return False | |
8 | |
9 class C(): | |
10 def __init__(self, data): | |
11 self.data = data | |
12 | |
13 def update(self, delta): | |
14 pass | |
15 | |
16 class visible(C): | |
17 def describe(self): | |
18 print self.data['desc'] | |
19 | |
20 def Main(): | |
21 parsed = {"visible":{"desc":"a visible thing"}} | |
22 print parsed | |
23 for key in parsed: | |
24 cl = string_to_comp(key) | |
25 if cl: | |
26 c = cl(parsed[key]) | |
27 print c.data | |
28 print c.data['desc'] | |
29 c.describe() | |
30 | |
31 if __name__ == "__main__" :Main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment