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.
Development
Install the package in editable mode with test dependencies:
pip install -e '.[test]'
Code quality
make lint
Testing
make test
Releasing on PyPI
- Update the
version
inpyproject.toml
. We use semantic versioning - Create and merge a PR branch called
release-x.x.x
- Pull from `main``
- At the command line, run
make tag
- Go to tags page, choose the most recent tag, 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.4.1.tar.gz
(4.1 kB
view details)
Built Distribution
listo-0.4.1-py3-none-any.whl
(3.6 kB
view details)
File details
Details for the file listo-0.4.1.tar.gz
.
File metadata
- Download URL: listo-0.4.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 393f87627732ba4c938237788afab591e75bba592fabf5b59d713cb6062cd2ed |
|
MD5 | a8a97d5d144cecdc3dc0e8cc245b76f9 |
|
BLAKE2b-256 | c2e2aaac0db27583d4e10d60f385a72bf3ef2491d338be65698145a733e8f139 |
File details
Details for the file listo-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: listo-0.4.1-py3-none-any.whl
- Upload date:
- Size: 3.6 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 | 1ab7455b452fd4e9cc0a9be1aa031522235837f343c8a22c3038677f1b3dba3b |
|
MD5 | bebcdd8561d590561557a8ff38fb10fd |
|
BLAKE2b-256 | f4e6838298930fe2ed0a11daa59da938b0b388098d327337c919609520fbea49 |