An improved version of the List type
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 afirst
method that returnsself[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 alisto
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.
Maintenance
Code quality
make lint
Testing
make test
Releasing on PyPI
- Update the
version
inpyproject.toml
. We use semantic versioning - At the command line, run
make tag
- Go to releases page and click
Draft a new release
Building the project locally
Go to the project root
pip install --upgrade build
python -m build
Test the project, forcing reinstall if necessary
pip install dist/listo-0.1.0-py3-none-any.whl --force-reinstall
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.3.0.tar.gz
(3.4 kB
view details)
Built Distribution
listo-0.3.0-py3-none-any.whl
(3.4 kB
view details)
File details
Details for the file listo-0.3.0.tar.gz
.
File metadata
- Download URL: listo-0.3.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 547baaa309bb88653c80ea40dd36dbdf1d7675c11c8f83dae795def069b94d9c |
|
MD5 | d74fc3b3f6afd986247faaa91e9f91e6 |
|
BLAKE2b-256 | 02ce5709c0e850218e666fca3d075380d812c158d5bf49d1625f3c134b36d9d0 |
File details
Details for the file listo-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: listo-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e685286c7deb9f01f0adc1f29839be05fcf93da7cd17ce122bb6f8624572788d |
|
MD5 | 2f6ae70821645ed320587ff2a21dcb5a |
|
BLAKE2b-256 | f0fd4eed9de1ace5efeca1ed2c12db0abf2eb2d562cb80787dc302eaf6a7c22a |