A package for Python utility functions.
Project description
About
A package for Python utility functions.
What is this package about? Is its aim to offer functionality like a multi-tool pocketknife? Or like the utility belt of a caped crusader? Well, the purpose of a bumbag is to put in all the things you need often! As such, the BumBag package is a collection of frequently used Python functions.
Dictionary definition
bumbag /ˈbʌmbæg/
(noun countable) -
a small bag attached to a long strap that you fasten around your waist to keep money, keys, and other small things in.
Installation
bumbag
is available on PyPI:
pip install bumbag
Usage
Easily flatten
an irregular list:
from bumbag import flatten
irregular_list = [
["one", 2],
3,
[(4, "five")],
[[["six"]]],
"seven",
[],
]
list(flatten(irregular_list, 8, [9, ("ten",)]))
['one', 2, 3, 4, 'five', 'six', 'seven', 8, 9, 'ten']
Quickly compare two Python sets with two_set_summary
:
from bumbag import two_set_summary
x = {"a", "c", "b", "g", "h"}
y = {"c", "d", "e", "f", "g"}
summary = two_set_summary(x, y)
print(summary["report"])
x (n=5): {'a', 'b', 'c', ...}
y (n=5): {'c', 'd', 'e', ...}
x | y (n=8): {'a', 'b', 'c', ...}
x & y (n=2): {'c', 'g'}
x - y (n=3): {'a', 'b', 'h'}
y - x (n=3): {'d', 'e', 'f'}
x ^ y (n=6): {'a', 'b', 'd', ...}
jaccard = 0.25
overlap = 0.4
dice = 0.4
disjoint?: False
x == y: False
x <= y: False
x < y: False
y <= x: False
y < x: False
Don't forget to check out more examples and the API Reference.
Contributing
Have you ever caught yourself thinking: "Ahh ... I need that function again. I have to copy it from another project."? If you have, why not sharing your awesome utility function with the rest of the world?
To do so, check out the contributing guidelines and the guide for developers. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
License
bumbag
was created by BumBag Developers.
It is licensed under the terms of the BSD 3-Clause license.
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.