Kurt Rose
Kurt Rose
```python def get_all(map, **defaults): return {key: map.get(key, default) for key, default in defaults.items()} ``` found this to be handy e.g. when extracting data from query parameters, flags or similar very...
find myself wanting to do ``` itertools.product('ABC', '123') ``` and get a result like ``` ['A1', 'A2', ... , 'C3'] ``` however, itertools always gives you back iterables of tuples
```python def _import_pkg_modules(package, excluded): pkg_path = os.path.dirname(package.__file__) for file in os.listdir(pkg_path): module, ext = os.path.splitext(file) if module in excluded or module.startswith("__"): continue if ext in ('.py', '.so'): import_module(package.__name__ + '.'...
this is so simple it almost looks like it shouldn't be a function, you should just do it in place ```python def _replaced(iter, old, new): '''return a copy of iter...
numpy multi-dimensional slices can be nice as a standalone capability use case: given the return of `fetchall()` from sqlalchemy / DBAPI2 database driver, drop the first column ```python nslice(rows)[:, 1:]...
```python def recursive_update(a, b): 'dict.update(), but recurse when both values are dicts' for k, v in b.items(): if v.__class__ is dict and a.get(k).__class__ is dict: a[k] = _recursive_update(a[k], v) else:...
might be handy to have this in a CLI type interface like stdlib in trace as well python -m tracemod json socket main.py
as I'm answering more and more questions, I'm starting to notice a pattern, maybe there's a path that can be documented level 1: specs are constants level 2: writing helper...
I don't want to "punch down" at another open source project, trying to keep it neutral and informative.