Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lodash for Python?

Tags:

Is there a library or something similar to lodash, for Python? We use the library extensively on our API and while we move on to creating a series of Python workers, it would make sense to create a similar structure to our API syntactics.

like image 951
stackunderflow Avatar asked Feb 10 '16 14:02

stackunderflow


People also ask

What is lodash good for?

Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. Lodash's modular methods are great for: Iterating arrays, objects, & strings. Manipulating & testing values.

How do you require lodash?

If you want to use lodash in your front-end, supposing you are using bower , you need to include lodash in your bower. json , do bower install and including lodash. js in your index by hand or using a tool to inject it like Gulp or Grunt .

What is NPM lodash?

Lodash is a JavaScript library that provides utility functions for common programming tasks using a functional programming paradigm; it builds upon the older underscore. js library. Lodash has several built-in utility functions that make coding in JavaScript easier and cleaner.


2 Answers

pydash is exactly like lodash, only for Python.

like image 117
Adam Boduch Avatar answered Sep 21 '22 03:09

Adam Boduch


pydash is something which you can use as a replacement of lodash in python. Almost everything is covered under it, the names of functions are also similar just keeping python's conventions as is.

Important: I've been using pydash for around 07 months, It helped me a lot. One thing which you should not forget is, avoid using pydash functions directly on self, its behaviour is very erratic and gives random results. I'm showing one example below.

Sample Class

class MyClass:     def get(self):        self.obj = {}        self.obj['a'] = True 

Usage class TestClass: def init(self): self.inst = MyClass()

   def test_function(self):       # **Not Recommended Method**       # _.get(self, "inst.a")    # shows random behavior        # **Highly recommended**       _.get(self.inst, "a")     # Will always return True 
like image 27
Mudassirkhan Avatar answered Sep 21 '22 03:09

Mudassirkhan