Created
July 12, 2021 02:00
-
-
Save borhan-kazimipour/55ab1dd985b7a529e9bf3a54f807b40d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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