knife is a powerful Python multitool loosely inspired by underscore.js but remixed for maximum pythonicity. knife concentrates power normally found dispersed across the universe of Python packages in one convenient shrink-wrapped package.
knife works with Python 2.6, 2.7, and 3.2. knife documentation can be found at http://readthedocs.org/docs/knife/en/latest/ or http://packages.python.org/knife/ 3 second knife --------------------- Things go in: >>> gauntlet = __(5, 4, 3, 2, 1) Things get knifed: >>> gauntlet.initial().rest().slice(1, 2).last() Things come out: >>> gauntlet.get() 3 Slightly More ------------------- knife features over 40 methods that can be chained into pipelines: >>> from knife import __ >>> __(5, 4, 3, 2, 1).initial().rest().slice(1, 2).last().get() 3 Or object-oriented style: >>> from knife import knife >>> oo = knife(('a', 1), ('b', 2), ('c', 3)) >>> oo.wrap(dict) >>> oo.map() >>> oo.get() {'a': 1, 'b': 2, 'c': 3} knife knives can roll thing in its pipeline back to the results of the immediately preceding steps, a baseline snapshot, or even the original arguments. >>> undone = __(1, 2, 3).prepend(1, 2, 3, 4, 5, 6) >>> undone.peek() [1, 2, 3, 4, 5, 6, 1, 2, 3] >>> undone.append(1).undo().peek() [1, 2, 3, 4, 5, 6, 1, 2, 3] >>> undone.append(1, 2).undo(2).peek() [1, 2, 3, 4, 5, 6, 1, 2, 3, 1] undone.snapshot().append(1, 2).baseline().peek() [1, 2, 3, 4, 5, 6, 1, 2, 3, 1] undone.original().peek() [1, 2, 3] >>> one.original().minmax().pipe(two).merge().back().max().get() 1000 >>> one.original().minmax().pipe(two).merge().back().sum().get() 1002 Installation ---------------- knife can be installed the usual ways from: http://pypi.python.org/pypi/knife/ Development ------------------- * Public repository: https://bitbucket.org/lcrees/knife. * Mirror: https://github.com/kwarterthieves/knife/ * Issue tracker: https://bitbucket.org/lcrees/knife/issues * License: BSD -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/