소스 검색

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__