Skip to main content

An improved version of the List built-in

Project description

listo

Listo is an enhanced version of the list type that aims to do the following:

  • Make behavior more consistent. No more methods with "in-place" changes. Every method call returns a value
  • Adds methods that are missing from the list type. For example, listo has a first method that returns self[0]
  • A list of arguments passed in will be converted to a listo object, but a single argument that is an iterator will be unpacked into a listo object. This is useful for when you want to pass in a generator or other iterator into a function that expects a list

Usage

First install it via pip, poetry, or whatever you use

pip install listo

Then use it in your code

from listo import listo

lst = listo(1, 2, 3)
assert lst.first() == 1
assert lst.last() == 2

Usage: How listo handles initial arguments

For arguments passed in, it just converts them to a listo object

lst = listo(1, 2, 3)
assert lst == [1, 2, 3]

lst2 = listo([1, 2, 3]) # list is unpacked
assert lst2 == [1, 2, 3]

lst3 = listo((1, 2, 3)) # tuple is converted and unpacked
assert lst3 == [1, 2, 3]

lst4 = listo([1, 2, 3], (1, 2))  # Two args mean nothing is unpacked
assert lst4 == [[1, 2, 3], (1, 2)]

This is different from standard Python iterator behavior.

Contributing to Listo

Have you tried using Listo and found it useful? Do you have ideas for how to make it better?

We welcome contributions from the community!

See CONTRIBUTING.md for details on how to set up your development environment to contribute to this project, run tests, check code quality, release new versions, and more.

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

listo-0.6.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

listo-0.6.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file listo-0.6.0.tar.gz.

File metadata

  • Download URL: listo-0.6.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for listo-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ba385153908f58538c762d31cc8825fa9a2b5b9a24fecc460b8697cac8b89a78
MD5 e8b2077c4b349060e493be34a286e90c
BLAKE2b-256 f2759263f1601561b5b7e20ac28da92d8edc6f0f5517305643ac21feb9efb849

See more details on using hashes here.

File details

Details for the file listo-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: listo-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for listo-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a472be9c3097e1c91adbdddb80679b14d74040a8a7d35624c268742af5ce6a7d
MD5 bd20bafe1f5fbbbac3498782832c8c77
BLAKE2b-256 5c605f1662b84feb84a23a9ac4b4b02358f5498e21758d5caa6949d58633bf8c

See more details on using hashes here.

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