Feedback.py 文件源码

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

项目:pythonwhat 作者: datacamp 项目源码 文件源码
def __init__(self, message, astobj = None):
        self.message = message
        self.line_info = {}
        try:
            if astobj is not None:
                if issubclass(type(astobj), (_ast.Module, _ast.Expression)):
                    astobj = astobj.body
                if isinstance(astobj, list) and len(astobj) > 0:
                    start = astobj[0]
                    end = astobj[-1]
                else:
                    start = astobj
                    end = astobj
                if  hasattr(start, "lineno") and \
                    hasattr(start, "col_offset") and \
                    hasattr(end, "end_lineno") and \
                    hasattr(end, "end_col_offset"):
                    self.line_info["line_start"] = start.lineno
                    self.line_info["column_start"] = start.col_offset
                    self.line_info["line_end"] = end.end_lineno
                    self.line_info["column_end"] = end.end_col_offset
        except:
            pass

# TODO FILIP: No used for now, come back to this later.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号