__init__.py 文件源码

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

项目:py-IoticAgent 作者: Iotic-Labs 项目源码 文件源码
def valid_identifier(name):
        """Determines whether the given name could be used a Python identifier"""
        try:
            name = ensure_unicode(name)
        except ValueError:
            return False

        if name in __KEYWORDS:
            return False

        try:
            root = _ast.parse(name)
        except:
            return False

        return (isinstance(root, _ast.Module) and
                len(root.body) == 1 and
                isinstance(root.body[0], _ast.Expr) and
                isinstance(root.body[0].value, _ast.Name) and
                root.body[0].value.id == name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号