Browse Source

attr from string test

Johann Woelper 9 years ago
parent
commit
da9744450a
1 changed files with 11 additions and 0 deletions
  1. 11 0
      attr_from_string.py

+ 11 - 0
attr_from_string.py

@@ -0,0 +1,11 @@
+class Test():
+    def __init__(self):
+        self.val = None
+
+    def setByString(self, string, value):
+        self.__dict__[string] = value
+    
+
+t = Test()
+t.setByString('val', 1)
+print t.__dict__