expandtabs.py 文件源码

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

项目:stig 作者: rndusr 项目源码 文件源码
def expand(lines, indent=4, maxwidth=100):
    """Expand all tabstops (\t) in each line intelligently

    "Intelligently" means that consecutive lines with the same amount of '\t'
    characters are treated like a table, giving each column the same space.

    Return `lines` with all tabs expanded
    """
    width = min(get_terminal_size()[0], maxwidth)
    expanded = []
    for section in _split_sections(_explode(lines, indent)):
        widths = _col_widths(section)
        for line in section:
            expanded.append(_join_line(line, widths, width))
    return expanded
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号