Skip to main content

Just a printing listed version function.

Project description

listele

Returns the given iterable in a columnar format as a string.


listele(li, column, /, *, spaces=30, find="", regex="", vertical=False) -> str
Parameter Description
li A list or dict to display. Dicts are formatted as "key: value".
column Number of columns in output.
spaces Minimum width of each column.
find Case-insensitive substring filter.
regex Regex pattern to filter elements (uses match).
vertical If True, fill columns top-to-bottom instead of left-to-right.
Return Description
str Formatted string.
Raises Description
TypeError If li is not iterable.
ValueError If column or spaces are invalid, or vertical is not supported for the given input.

Examples

Basic usage:

print(listele(range(1, 13), 4))
1                             2                             3                             4
5                             6                             7                             8
9                             10                            11                            12

Filtering with find:

li = ['apple', 'apricot', 'banana', 'cherry', 'avocado', 'blueberry']
print(listele(li, 3, find="a"))
apple                         apricot                       banana
avocado

Filtering with regex:

li = ['file1.txt', 'file2.txt', 'image1.png', 'image2.png', 'data.csv']
print(listele(li, 3, regex=".*\\.txt$"))
file1.txt                     file2.txt

Vertical (top to bottom):

print(listele(range(1, 10), 3, vertical=True))
1                             4                             7
2                             5                             8
3                             6                             9

Dictionary:

d = {'name': 'Ali', 'age': 25, 'city': 'Istanbul', 'job': 'dev', 'lang': 'Python', 'tool': 'vim'}
print(listele(d, 2, spaces=25))
name: Ali                age: 25
city: Istanbul           job: dev
lang: Python             tool: vim

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

listele-3.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

listele-3.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file listele-3.0.0.tar.gz.

File metadata

  • Download URL: listele-3.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for listele-3.0.0.tar.gz
Algorithm Hash digest
SHA256 deb8e8d20f9a5451102273932a37b1217801139fc37aeb58560cae2e6c7fe456
MD5 a539f571f1cf9316c6f9f631573ca0a4
BLAKE2b-256 ecaf1a6ab0c80e18ae855dad7c005bf1b17848543dcd842b05aeb39313df2d41

See more details on using hashes here.

File details

Details for the file listele-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: listele-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for listele-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a957abaed7dfd258a183a649d53195ac2879a4aa6a3984be1518c8f0d746257b
MD5 b4b7a77385d3f88e4b3d4e8ee7e65c14
BLAKE2b-256 4a584b6b5c54d7f330a013e40f7eea7a611f2a82fa3156edd0c4d52c9c330545

See more details on using hashes here.

Supported by

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