Lodash for Python?

岁酱吖の 提交于 2019-12-04 23:15:26

pydash is exactly like lodash, only for Python.

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

Well I'm not sure if this is exactly what you're looking for but when I think of javascript libraries like underscore and Lodash, I think of libraries that add more functional programming functions(though I do believe both underscore and lodash have a little more utility than that) to a language.

There are a bunch of Python Libraries that try and add some of the same functionality. A quick search got me pytoolz https://github.com/pytoolz/toolz which I don't have much experience with but looks interesting. If that isn't what you're looking for, try searching for other functional programming python libraries until you find one you like.

Hope that helped

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!