def magic():
"""
Returns a string which represents Python code that copies instance
variables to their local counterparts. I.e:
var = self.var
var2 = self.var2
"""
s = ""
for var, value in inspect.getmembers(sys._getframe(1).f_locals["self"]):
if not (var.startswith("__") and var.endswith("__")):
s += var + " = self." + var + "\n"
return s
评论列表
文章目录