浏览代码

attr from string test

Johann Woelper 9 年之前
父节点
当前提交
da9744450a
共有 1 个文件被更改,包括 11 次插入0 次删除
  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__