Skip to main content

collist is a simple module which provides the function collist(), the single purpose of which is to columnate lists of output for printing to the terminal. It is very much like the unix command column, but it works on python iterables. This package also exports the command cols which is similar to column but works better (on my system), though it has fewer options; see cols --help.

The program uses the tput command internally, and therefore will not work with Windows and other strange, non-POSIX operation systems.

Monkey Patch collist into the Python Interactive Prompt

The Python interactive prompt print the representation of the return value of any expression you give it. If that return value is a list, dictionary, or tuple, It returns the literal that will produce the object.

When these collection objects get rather longer, printing them sucks. collist is designed to make lists of things look better. collist has a representation function which will output a nicely columnated repr of a python dictionary, list or tuple. This repr is a valid python literal.

In order to get this behavior in the standard interactive prompt or bpython, add this to your ~/.pystart:

import sys # if you haven't already.
from collist import displayhook

sys.displayhook = displayhook

Then, you’ll get nicely columnated list, tuples and dictionaries back in the interactive prompt.

>>> [i for i in ('foo bar bing ' * 15).split()]
['foo',  'bar',  'bing', 'foo',  'bar',  'bing', 'foo',  'bar',
 'bing', 'foo',  'bar',  'bing', 'foo',  'bar',  'bing', 'foo',
 'bar',  'bing', 'foo',  'bar',  'bing', 'foo',  'bar',  'bing',
 'foo',  'bar',  'bing', 'foo',  'bar',  'bing', 'foo',  'bar',
 'bing', 'foo',  'bar',  'bing', 'foo',  'bar',  'bing', 'foo',
 'bar',  'bing', 'foo',  'bar',  'bing']

Nice! This is what the people want. There is a bug at the moment where the terminal size is stuck at whatever it was when the interactive prompt was started. I assume this has something to do with tput getting the terminal size from sterr, but I’m not really sure. If anyone has a fix, I will be glad to accept a patch.

Also this patch won’t work in ipython, since it has it’s own replacement for displayhook, of which I know nothing. It prints nicely already. kind of.

Metadata

Release files for collist 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for collist 0.5
File Size Uploaded Provenance
collist-0.5.tar.gz 3.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for collist 0.5
File Interpreter ABI Platform
collist-0.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 9.8 kB

Release files / collist-0.5.tar.gz

Download URL collist-0.5.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e4d443ea9ae63d45733ca5a84ff9baad2133bd933a5021c0731ba1d2108a838e
BLAKE2b-256 checksum
How to use checksums
70533b1f0829d7559ec1dc2e7088746b417ca8baeaed5cc8620545c25587043a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / collist-0.5-py2.py3-none-any.whl

Download URL collist-0.5-py2.py3-none-any.whl
Size 5.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c0ad9936f63a1ca7678cb3afadd7ea3da2a9dccbbea7cd0d2452f12e04e132b8
BLAKE2b-256 checksum
How to use checksums
7fad5aa5ea7d27133cb40eb5a89ed01caba4db3b8e4a1e72415647d709be3e90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for collist 0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page