myinspect.py 文件源码

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

项目:my_utils 作者: aploium 项目源码 文件源码
def getblock(lines):
        """Extract the block of code at the top of the given list of lines."""
        blockfinder = inspect.BlockFinder()
        try:
            tokens = inspect.tokenize.generate_tokens(iter(lines).__next__)
            for _token in tokens:
                blockfinder.tokeneater(*_token)
        except (inspect.EndOfBlock, IndentationError):
            pass
        return lines  # different to builtin inspect is here
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号