parser.py 文件源码

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

项目:cohesion 作者: mschwager 项目源码 文件源码
def get_instance_variables(node, bound_name_classifier=BOUND_METHOD_ARGUMENT_NAME):
    """
    Return instance variables used in an AST node
    """
    node_attributes = [
        child
        for child in ast.walk(node)
        if isinstance(child, ast.Attribute) and
        get_attribute_name_id(child) == bound_name_classifier
    ]
    node_function_call_names = [
        get_object_name(child)
        for child in ast.walk(node)
        if isinstance(child, ast.Call)
    ]
    node_instance_variables = [
        attribute
        for attribute in node_attributes
        if get_object_name(attribute) not in node_function_call_names
    ]
    return node_instance_variables
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号