Skip to main content

Odd Utility Collection Hub

Project description

ouch

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


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.28.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ouch-0.0.28-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file ouch-0.0.28.tar.gz.

File metadata

  • Download URL: ouch-0.0.28.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ouch-0.0.28.tar.gz
Algorithm Hash digest
SHA256 13eda4d236ebbfe775e8a66bf4d90fc93b181fbd5d62b1e16fbb30dc13cc106e
MD5 7f2474294cd8099f61462c9d268e1eb6
BLAKE2b-256 7be91831788d70aaa1ec4ab5a7132414ad4b6f9345626635e2d5b30d71e82124

See more details on using hashes here.

File details

Details for the file ouch-0.0.28-py3-none-any.whl.

File metadata

  • Download URL: ouch-0.0.28-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ouch-0.0.28-py3-none-any.whl
Algorithm Hash digest
SHA256 69a209adf84fc3c34de769fb2f133f8419b8100deb51f9a130d523f1d4d29f44
MD5 85557293e0705a7b4b4814f1a44ce5b1
BLAKE2b-256 03351a4a819ba80d4123fd25fc1683f949f4e535d6868c6fe232e68e6ccc6567

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page