Some tiny python utils so I can be lazier.
Project description
python-utils
So maybe I stop writing the same things over and over.
Installation
# Python 3.9+ only (due to PEP 585 type annotations)
pip install mbforbes-python-utils
Usage
from mbforbes_python_utils import read, write, flatten
# read() removes leading/trailing whitespace.
contents = read("foo.txt")
# write() creates intermediate directories if needed.
# Pass `info_print = False` to disable printing.
write("bar/baz.txt", contents)
# flatten() flattens lists.
flatten([[1, [2, [3]]]]) # -> [1, 2, 3]
Tests
python test_mbforbes_python_utils.py
Releasing
I don't do this enough to remember how to do it
# Increment version in setup.py. Then,
pip install twine wheel
python setup.py sdist bdist_wheel
twine check dist/*
# If the above failed, `rm -rf build/ dist/` before retrying
twine upload dist/*
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
Built Distribution
Close
Hashes for mbforbes_python_utils-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8dff19b03eaf42f01b05d24c45c9879f88a33b209a6aba237bd8c9b9f0a0563 |
|
MD5 | 426db4abb47635ce2bf69e5b5839c5b9 |
|
BLAKE2b-256 | b2a86122c51020a84f118d5b4c4df6daa3855288689f454e22b01fb1213f5452 |
Close
Hashes for mbforbes_python_utils-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc4a096862fb16f291a7bae906026284e4787173969f3e6c22adabd7604c0b09 |
|
MD5 | a4ef55f7415d40cacadf61b37a7e55e2 |
|
BLAKE2b-256 | 920224582982bcd920f8762da10ba4c52d6f721b724e272267fc2cb5bef18492 |