lscolumn
Print a list of strings in columns like in ls.
Description
Two styles are available -- BSD-style and GNU-style. Let's see through example:
>>> import lscolumn
>>> lscolumn.pprint(['hello', 'hola world', 'greetings', 'hello again and again'],
... total_width=60, style='BSD')
hello greetings
hola world hello again and again
>>> lscolumn.pprint(['hello', 'hola world', 'greetings', 'hello again and again'],
... total_width=60, style='GNU')
hello hola world greetings hello again and again
In BSD-style, the widths of the columns are the same, whereas in GNU-style, they are different. When formatting long list, BSD-style is faster than GNU-style, but GNU-style is more compact.
CJK (wide) characters are well supported thanks to cjkjust.
Installation
pip install lscolumn
Functions and Classes
For detailed help, try help(...) in Python REPL.
pprint(strings, total_width=None, style='BSD', file=None): print in columns the list of stringsstringsBSDFormatter: the BSD-style formatter (see example below)GNUFormatter: the GNU-style formatter (see example below)
Example using BSDFormatter
import lscolumn
bsd = lscolumn.BSDFormatter(total_width=80)
# print one list
bsd.pprint(['hello', 'hola world', 'greetings'])
# print another list using the same configuration
bsd.pprint(['greetings', 'hello again and again'])
# print yet another list to `outfile`
with open('filename.txt', 'w') as outfile:
bsd.pprint(['hello', 'hola world'], file=outfile)
The same applies to GNUFormatter.
Metadata
Release files for lscolumn 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lscolumn-0.1.2.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lscolumn-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / lscolumn-0.1.2.tar.gz
| Download URL | lscolumn-0.1.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77b0e967abe57fbb0c9705273cd291b7278cdfd837d7973b8b6642e11a529e19
|
|
BLAKE2b-256 checksum How to use checksums |
1e746acab3a0d133df35eba200de4b1fea5a22cba18f7a7a89f4bf4ff5584806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Release files / lscolumn-0.1.2-py3-none-any.whl
| Download URL | lscolumn-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f53453202f614a9efa5351224663db45f28acb68332c04969873d3eaa880ca3
|
|
BLAKE2b-256 checksum How to use checksums |
a25108c1d6497fa9d1895385baa12ebc8a9e782aaeafb5e588e4bba2c12613ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|