recipe-362305.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:code 作者: ActiveState 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号