Funky is a small package of a few useful functional constructs in python.
It orignated by extracting the functionnal utility functions from Gittle.
Funky has no external dependencies besides the Python standard library and Python 2.6+.
pip install funky
importfunkysomelist= [9, 4, 9, 4, 3]
# Unique does not preserve order (could change)# However unique preserves type, if your input is a list your output will be a list, ...funky.unique(somelist) # [9, 4, 3]importfunky# Filter out not true valuesfunky.true_only(["good", 9, None, True, False]) # ["good", 9, True]importfunky# Some "collection"objects= [
{
'age': 55'other_attribute': 88
},
{
'age': 33
}
]
# Pluck works with dictionary keys as well as object attributes# pluck preserves orderfunky.pluck(objects, 'age') # [55, 33]importfunky# Hash supports hashingfunky.hash({
'key': 'value'
}) # -8073414452536086510