[Python] Try pydash of the Python version of lodash

Try pydash from lodash for Python

TL;DR The company develops the front side with React and the back end with Django. I often use a library called lodash on the front side, but it's insanely convenient, and when I write Python after that, I sometimes feel frustrated because there is no lodash. One day when I was suffering from such frustration, I found a library called pydash, which can be called a Python version of lodash, so I will introduce it.


It is said that the available Ptyhon version is 2.6 or higher, or 3.3 or higher, so I will try it with Python 3.7.6 as appropriate.

$ pip install pydash

Touch it lightly

>>> import pydash
>>> from pydash import flatten

# Arrays
>>> 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]
>>> pydash.remove([{'name': 'moe', 'age': 40}, {'name': 'larry', 'age': 50}], lambda x: x['age'] < 50)
[{'name': 'moe', 'age': 40}]

# Collections
>>> pydash.map_([{'name': 'moe', 'age': 40}, {'name': 'larry', 'age': 50}], 'name')
['moe', 'larry']
>>> pydash.filter_([{'name': 'moe', 'age': 40}, {'name': 'larry', 'age': 50}], {'age': 40})
[{'name': 'moe', 'age': 40}]

# Functions
>>> curried = pydash.curry(lambda a, b, c: a + b + c)
>>> curried(1, 2)(3)

# 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()

It's wonderful. It's not inferior to lodash.

Difference from lodash

As mentioned above, there are subtle differences in function names such as pydash.map_ and pydash.filter_.


I think it's quite convenient. The lodash documentation is fairly easy to read, so it seems that development will progress while referring to it.


https://pydash.readthedocs.io/en/latest/ https://lodash.com/

Recommended Posts

[Python] Try pydash of the Python version of lodash
Try the python version of emacs-org parser orgparse
Try the free version of Progate [Python I]
pyenv-change the python version of virtualenv
Change the Python version of Homebrew
About the virtual environment of python version 3.7
the zen of Python
A note about the python version of python virtualenv
Try using the collections module (ChainMap) of python3
Align the version of chromedriver_binary
Towards the retirement of Python2
About the ease of Python
Let's use the Python version of the Confluence API module.
Check OpenSSL version of python 2.6
About the features of Python
The Power of Pandas: Python
Try scraping the data of COVID-19 in Tokyo with Python
Try to get the function list of Python> os package
Try to automate the operation of network devices with Python
What is the default TLS version of the python requests module?
[Python] Tuple version of prefecture pull-down
Test the version of the argparse module
The story of Python and the story of NaN
Raise the version of pyenv itself
[Python] The stumbling block of import
First Python 3 ~ The beginning of repetition ~
Try the Python LINE Pay SDK
Existence from the viewpoint of Python
Ideone> Python version: 3.5 (as of August 29, 2017)
[Python] Understanding the potential_field_planning of Python Robotics
Review of the basics of Python (FizzBuzz)
Try using the Python Cmd module
About the basics list of Python basics
Learn the basics of Python ① Beginners
The story that the version of python 3.7.7 was not adapted to Heroku
[Cloudian # 9] Try to display the metadata of the object in Python (boto3)
[Python] Try to graph from the image of Ring Fit [OCR]
Try transcribing the probability mass function of the binomial distribution in Python
Try python
First python ② Try to write code while examining the features of python
How to update the python version of Cloud Shell on GCP
Change the length of Python csv strings
Try using the Wunderlist API in Python
Check the behavior of destructor in Python
[Python3] Understand the basics of Beautiful Soup
Try using the Kraken API in Python
How to check the version of Django
The story of making Python an exe
Learning notes from the beginning of Python 1
Check the existence of the file with python
[Python] Understand the content of error messages
[Python3] Rewrite the code object of the function
I didn't know the basics of Python
The result of installing python in Anaconda
[python] Checking the memory consumption of variables
Check the path of the Python imported module
The story of manipulating python global variables
[python] [meta] Is the type of python a type?
Migemo version of the: find command,: mfind
The basics of running NoxPlayer in Python
Pandas of the beginner, by the beginner, for the beginner [Python]