columnize 0.3.9
pip install columnize==0.3.9
Released:
Format a simple (i.e. not nested) list into aligned columns.
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Python Software Foundation License (PSF2)
- Author: Rocky Bernstein
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
- Topic
Project description
In showing a long lists, sometimes one would prefer to see the value arranged aligned in columns. Some examples include listing methods of an object, listing debugger commands, or showing a numeric array with data aligned.
This is a Python module to format a simple (i.e. not nested) list into aligned columns. A string with embedded newline characters is returned.
Setup
$ python
>>> import columnize
With String data
Each column is only as wide as necessary. By default, columns are separated by two spaces; one was not legible enough. Set colsep to adjust the string separate columns. Set displaywidth to set the line width.
>>> g = ('bibrons', 'golden', 'madascar', 'leopard', 'mourning', 'suras', 'tokay')
>>> print(columnize.columnize(g, displaywidth=15))
bibrons suras
golden tokay
madascar
leopard
mourning
>>> print(columnize.columnize(g, displaywidth=19, colsep=' | '))
bibrons | mourning
golden | suras
madascar | tokay
leopard
>>> print(columnize.columnize(g, displaywidth=18, colsep=' | ', ljust=False))
bibrons | suras
golden | tokay
madascar
leopard
Normally, consecutive items go down from the top to bottom from the left-most column to the right-most. If arrange_vertical is set false, consecutive items will go across, left to right, top to bottom.
With numeric data
>>> print(columnize.columnize(['1', '2', '3', '4'], displaywidth=6)) # => '1 3\n2 4\n'
1 3
2 4
>>> print(columnize.columnize(list(range(1,6)), displaywidth=8))
1 3 5
2 4
By default entries are left justified:
>>> print(columnize.columnize(list(range(1,16)), displaywidth=10))
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15
but you can change that with ljust or if arrange_array is set to True:
>>> print(columnize.columnize(list(range(1,16)), displaywidth=10, ljust=False))
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15
>>> print(columnize.columnize(list(range(1,5)), opts={'arrange_array':True, 'displaywidth':6}))
[1, 2
3, 4]
Credits
This module (essentially one function) was adapted from a private method of the same name from Python’s cmd module. Some adjustments and generalizations have been made.
Other stuff
Authors: Rocky Bernstein rockyb@rubyforge.org
License: MIT
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Python Software Foundation License (PSF2)
- Author: Rocky Bernstein
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
- Topic
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file columnize-0.3.9.tar.gz
.
File metadata
- Download URL: columnize-0.3.9.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fabb8e0e3a2241b18f31bf2416934f338c6ca1d3bbbaf434979813bf2a3e442b |
|
MD5 | 630393a1ffff17d8ed4d5342764ea1ce |
|
BLAKE2b-256 | 309ec203e545f607ded51db8552f0b908d4dbdd86d4a4a41c949b72ef7b17521 |
File details
Details for the file columnize-0.3.9-py3.3.egg
.
File metadata
- Download URL: columnize-0.3.9-py3.3.egg
- Upload date:
- Size: 8.8 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dff747b1678aee3ae74b028d7b35bf4e19f845877cbd7337904ecced143e0ea3 |
|
MD5 | 00c29d4587c818e8994fc700e90fc52c |
|
BLAKE2b-256 | 846eae56bb37af3fa8c415605cd16506ca51c98b42926d9e9b69b6aedfa7ad25 |
File details
Details for the file columnize-0.3.9-py3.2.egg
.
File metadata
- Download URL: columnize-0.3.9-py3.2.egg
- Upload date:
- Size: 8.9 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5b5c1a668ae6b13d3fd12048033c444c51e2070edb9a195f97483efc60b37e7 |
|
MD5 | 701147a6d5a6764fb6606d0244bdfa0b |
|
BLAKE2b-256 | a48a49a77afd4c6146f98a89fb2c21a4f6f3d934f1fe6dd56d6ce6d8d2ff679e |
File details
Details for the file columnize-0.3.9-py3-none-any.whl
.
File metadata
- Download URL: columnize-0.3.9-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30d10054913f6ad49cc942eb5d26a116cf88d3c603a24a6c2863b90b340b84ad |
|
MD5 | caaea8f4e95cb74becfd55f3028985c8 |
|
BLAKE2b-256 | 6540486b7f407530592a2babb1b2d954e9e96af272e126031978176190027c37 |
File details
Details for the file columnize-0.3.9-py2.7.egg
.
File metadata
- Download URL: columnize-0.3.9-py2.7.egg
- Upload date:
- Size: 8.8 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb6df1ac612f5b5a98a53b328f83856e588f5652bcf2423b89988a96ed4aa40c |
|
MD5 | 0c3cbac13110776e0927c3117813c132 |
|
BLAKE2b-256 | 8ec69b566ed5e5a88f69b7c57f0ee5d8bea2672ed82131ad2f3617cdb495d87f |
File details
Details for the file columnize-0.3.9-py2.6.egg
.
File metadata
- Download URL: columnize-0.3.9-py2.6.egg
- Upload date:
- Size: 8.9 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27517feb1922a4d4d0543ef984a9e0595b807d9d75d62e82c24ad7d4e614c49d |
|
MD5 | 278b947cabccecec76aa77070d9b6f7d |
|
BLAKE2b-256 | 74e2dfb1c8ad9386838aed4cc01948c6a5c8f42f361b22454ece2505a7863d39 |
File details
Details for the file columnize-0.3.9-py2.5.egg
.
File metadata
- Download URL: columnize-0.3.9-py2.5.egg
- Upload date:
- Size: 8.8 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3ae6a5824c87f680645d4011841330dc4c12311fe368b8f84c0a2312bd32481 |
|
MD5 | 93d1b2b829eda53677b19679a4ff967b |
|
BLAKE2b-256 | c0fe46188d83896c14d42adbf18ff53693989444e57bd647cbc45986913a77fe |
File details
Details for the file columnize-0.3.9-py2.4.egg
.
File metadata
- Download URL: columnize-0.3.9-py2.4.egg
- Upload date:
- Size: 8.9 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a98ce357f68e5e5a15b094e4d4f192fcd1eba5bfdeea11ec2ad4c5a3901ea76 |
|
MD5 | 3b61c4945ba9005291b8ab6d2f55decc |
|
BLAKE2b-256 | 1d675e74077990e8c5eeb65816719a252b0f4efc8bc63ed76458cd171032383f |
File details
Details for the file columnize-0.3.9-py2-none-any.whl
.
File metadata
- Download URL: columnize-0.3.9-py2-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f32d122d5e5c487357a710545caf7aca899fe6bcabca0e94ffdf434e27b6757 |
|
MD5 | 77c3a92451b7ffb386ad42e8e4c781f4 |
|
BLAKE2b-256 | a12752e422c33193abd81d22988f2188111d57b6c3fb5a18c2b571f3a86a1e44 |