Skip to content

Instantly share code, notes, and snippets.

@borhan-kazimipour
Created July 12, 2021 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borhan-kazimipour/55ab1dd985b7a529e9bf3a54f807b40d to your computer and use it in GitHub Desktop.
Save borhan-kazimipour/55ab1dd985b7a529e9bf3a54f807b40d to your computer and use it in GitHub Desktop.
# ref: https://pydash.readthedocs.io/en/latest/
import pydash
# Arrays
pydash.flatten([1, 2, [3, [4, 5, [6, 7]]]])
# [1, 2, 3, [4, 5, [6, 7]]]
pydash.flatten_deep([1, 2, [3, [4, 5, [6, 7]]]])
# [1, 2, 3, 4, 5, 6, 7]
# Collections
pydash.map_([{'name': 'moe', 'age': 40}, {'name': 'larry', 'age': 50}], 'name')
# ['moe', 'larry']
# Functions
curried = pydash.curry(lambda a, b, c: a + b + c)
curried(1, 2)(3)
# 6
# Objects
pydash.omit({'name': 'moe', 'age': 40}, 'age')
# {'name': 'moe'}
# Utilities
pydash.times(3, lambda index: index)
# [0, 1, 2]
# Chaining
pydash.chain([1, 2, 3, 4]).without(2, 3).reject(lambda x: x > 1).value()
# [1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment