qazbnm456 / py_tabwriter

A Python package for formatting columns of text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyTabWriter

A package for formatting text in aligned columns; inspired by Go's text/tabwriter package.

Example

>>> from py_tabwriter import TabWriter
>>> tw = TabWriter()
>>> tw.writeln('first\tsecond\tthird')
>>> tw.write('x\txx\txxx\n')
>>> tw.write(['column 1', 'column 2', 'column 3'])
>>> print(str(tw))
first    second   third
x        xx       xxx
column 1 column 2 column 3
>>> tw.alignment = 'r'
>>> print(str(tw))
   first   second    third
       x       xx      xxx
column 1 column 2 column 3

About

A Python package for formatting columns of text

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%