Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxme1/jboc
No dependencies, no paradigm - Just a Bunch Of Code
https://github.com/maxme1/jboc
python
Last synced: about 1 month ago
JSON representation
No dependencies, no paradigm - Just a Bunch Of Code
- Host: GitHub
- URL: https://github.com/maxme1/jboc
- Owner: maxme1
- License: mit
- Created: 2023-02-20T13:59:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-20T14:33:15.000Z (almost 2 years ago)
- Last Synced: 2024-11-23T07:51:36.588Z (2 months ago)
- Topics: python
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## No dependencies, no paradigm - Just a Bunch Of Code
A small collection of some useful code that didn't fit into any package that I know of.
# Examples
Turn a generator function into a function that returns a list:
```python
from jboc import collect@collect
def odd_numbers(n):
for i in range(n):
yield 2 * i + 1# not a generator anymore
odd_numbers(3) == [1, 3, 5]
```Same as before, but gather the values into a different container, e.g. a dict:
```python
from jboc import composed@composed(dict)
def vals_to_squares(values):
for v in values:
yield v, v ** 2# the pairs are gathered in a dict
vals_to_squares([3, 2, 8]) == {3: 9, 2: 4, 8: 64}
```# Install
```shell
pip install jboc
```