Skip to main content

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/ *.egg-info` 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

mbforbes_python_utils-0.5.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

mbforbes_python_utils-0.5.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file mbforbes_python_utils-0.5.0.tar.gz.

File metadata

  • Download URL: mbforbes_python_utils-0.5.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for mbforbes_python_utils-0.5.0.tar.gz
Algorithm Hash digest
SHA256 c6ac89147e3152531e0c0beb373adb6b2a76d808e20f111721cde5ab4b64ffd3
MD5 dee41e182c62607ef754bd8c356f14ff
BLAKE2b-256 1f1627eab93b925f93ab190bd6d4b3f589100d00ef58f4d1e7c7cbc91b32d74d

See more details on using hashes here.

File details

Details for the file mbforbes_python_utils-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mbforbes_python_utils-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea407a05b1c7321e175a37f8216c62dbf532666d6e234375f630fe30d42a603c
MD5 fa37054afc25e92ae5da549b9bb39c51
BLAKE2b-256 0eabba1d7294cba6535431e5fda182c8eff12f3e81c89cae78485b19645e06da

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