Prechádzať zdrojové kódy

attr from string test

Johann Woelper 9 rokov pred
rodič
commit
da9744450a
1 zmenil súbory, kde vykonal 11 pridanie a 0 odobranie
  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__