Skip to main content

Create text-based columnified content suitable for console output from list of strings

Project description

columnify

PyPI - Version PyPI - Python Version


Table of Contents

Quick Start

Source

import shutil

import columnify


given: list[str] = [
  "Canidae",
  "Felidae",
  "Cat",
  "Cattle",
  "Dog",
  "Donkey",
  "Goat",
  "Guinea pig",
  "Horse",
  "Pig",
  "Rabbit",
  "Fancy rat varieties",
  "laboratory rat strains",
]

output: str = columnify.columnify(given, shutil.get_terminal_size().columns)

print(output)

Result

Canidae  Cat     Dog     Goat        Horse  Rabbit               laboratory rat strains
Felidae  Cattle  Donkey  Guinea pig  Pig    Fancy rat varieties

Installation

pip install columnify

API

Methods

output: str = \
    columnify(
        items: list[str],
        line_width: int,
        indent: int = 0,
        delimiter: str = '  ',
        horizon_first: bool = False) -> str

License

columnify is distributed under the terms of the MPL-2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

columnify-0.0.1.tar.gz (10.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page