ouch
Odd Utiltiy Collection Hub.
ouch is a collection of utilities that are based on and aligned with foc.
$ pip install -U ouch
from ouch import *
# soft flatten
>>> flatten([1, [2, 3, (4, 5)]])
[1, 2, 3, (4, 5)]
# hard flatten
>>> [1, [(2,), [[{3}, (x for x in range(3))]]]] | flat | collect
[1, 2, 3, 0, 1, 2]
# 'shell' command
>>> shell(f"du -hs ouch/__init__.py 2>/dev/null") | fst | ob(_.split)()
['40K', 'ouch/__init__.py']
# 'ls' command
>>> ls(".", r=True, grep="^(ouch).*py$")
['ouch/__init__.py']
# poor man's dot-accessible dict, 'dmap' and pretty-printer 'pp'
>>> d = dmap(name="yunchan lim", age=19)
>>> d.cliburn.semifinal.concerto = "Mozart Piano Concerto No.22, K.482"
>>> d.cliburn.semifinal.recital = "Liszt 12 Transcendental Etudes"
>>> d.cliburn.final = "Rachmaninov Piano Concerto No.3, Op.30"
>>> d | pp
cliburn | final | Rachmaninov Piano Concerto No.3, Op.30
semifinal | concerto | Mozart Piano Concerto No.22, K.482
recital | Liszt 12 Transcendental Etudes
name | yunchan lim
# poor man's 'tabulate'
>>> data = [['Name', 'Age'], ['Sofia', 9], ['Maria', 7]]
>>> print(tabulate(data, style='grid')) # style={'org', 'markdown', ...}
+-------+-----+
| Name | Age |
+=======+=====+
| Sofia | 9 |
+-------+-----+
| Maria | 7 |
+-------+-----+
# poor man's progress bar, 'tracker'
>>> for batch in tracker(dataloader, "training"): # single progress bar
... model(batch)
>>> for i in tracker(range(10), "outer"): # nested progress bars
... ...
... for j in tracker(range(20), "inner"):
... ...
>>> g = (x for x in range(100))
>>> for item in tracker(g, "task", total=100): # generator with known length
... process(item)
# and see more poor man's things in 'ouch'
Metadata
Release files for ouch 0.0.32
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ouch-0.0.32.tar.gz | 20.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ouch-0.0.32-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.6 kB
Release files / ouch-0.0.32.tar.gz
| Download URL | ouch-0.0.32.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f58645c4723b117bfcea06554387340980e057347aa551570a593bbfb413393
|
|
BLAKE2b-256 checksum How to use checksums |
370916cb7685b28972dd6dc52258932cdb7cad314ef35d8cf6e7f9e9fd359cdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / ouch-0.0.32-py3-none-any.whl
| Download URL | ouch-0.0.32-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb61f014637c048b73f1d59d28d63f7647e92fafba6d725d6faa5abe51605ad5
|
|
BLAKE2b-256 checksum How to use checksums |
6fcb43b27a82fef93c00256b7836fb1523785182fdbf0e432ba1e4cab9fd89f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|