Odd Utility Collection Hub
Project description
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'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ouch-0.0.31.tar.gz
(20.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ouch-0.0.31-py3-none-any.whl
(18.9 kB
view details)
File details
Details for the file ouch-0.0.31.tar.gz.
File metadata
- Download URL: ouch-0.0.31.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f573863f0b5da5448c7e4f5c297de6fb405efdaaece38f4882cadc73220f383
|
|
| MD5 |
170cd54ef2fcc70e1489ee13f420b8c6
|
|
| BLAKE2b-256 |
6c3177ed95790f23f901fd5c314ebad17a50d314df40d38fd4deb3f2a0db178a
|
File details
Details for the file ouch-0.0.31-py3-none-any.whl.
File metadata
- Download URL: ouch-0.0.31-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36ac200419c510f009654744e1f199be40c49d99cf43b58452d058c8149ae671
|
|
| MD5 |
3d677151567cc89f7316f283a0a42e68
|
|
| BLAKE2b-256 |
ce2fc7ae4f1e1409e8f25dce814ab8e20219853c4ed97fab310dc8d23c0665e3
|