astmatch.py 文件源码

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

项目:pyq 作者: caioariede 项目源码 文件源码
def iter_node(self, node):
        silence = (ast.Expr,)

        if not isinstance(node, silence):
            try:
                body = node.body

                # check if is iterable
                list(body)

            except TypeError:
                body = [node.body]

            except AttributeError:
                body = None

            yield node, body

        for attr in ('value', 'func', 'right', 'left'):
            if hasattr(node, attr):
                value = getattr(node, attr)
                # reversed is used here so matches are returned in the
                # sequence they are read, eg.: foo.bar.bang
                for n in reversed(list(self.iter_node(value))):
                    yield n
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号