transformations.py 文件源码

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

项目:ITAP-django 作者: krivers 项目源码 文件源码
def getIfBranches(a):
    """Gets all the branches of an if statement. Will only work if each else has a single line"""
    if type(a) != ast.If:
        return None

    if len(a.orelse) == 0:
        return [a]
    elif len(a.orelse) == 1:
        tmp = getIfBranches(a.orelse[0])
        if tmp == None:
            return None
        return [a] + tmp
    else:
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号