Lodash Differences¶
Naming Conventions¶
pydash adheres to the following conventions:
Function names use
snake_caseinstead ofcamelCase.Any Lodash function that shares its name with a reserved Python keyword will have an
_appended after it (e.g.filterin Lodash would befilter_in pydash).Lodash’s
toArray()is pydash’sto_list().Lodash’s
functions()is pydash’scallables(). This particular name difference was chosen in order to allow for thefunctions.pymodule file to exist at root of the project. Previously,functions.pyexisted inpydash/api/but inv2.0.0, it was decided to move everything inapi/topydash/. Therefore, to avoid import ambiguities, thefunctions()function was renamed.Lodash’s
is_native()is pydash’sis_builtin(). This aligns better with Python’s builtins terminology.
Callbacks¶
There are a few differences between extra callback style support:
Pydash has an explicit shallow property access of the form
['some_property']as inpydash.map_([{'a.b': 1, 'a': {'b': 3}}, {'a.b': 2, 'a': {'b': 4}}], ['a.b'])would evaulate to[1, 2]and not[3, 4](as would be the case for'a.b').
Extra Functions¶
In addition to porting Lodash, pydash contains functions found in lodashcontrib, lodashdeep, lodashmath, and underscorestring.
Function Behavior¶
Some of pydash’s functions behave differently:
pydash.utilities.memoize()uses all passed in arguments as the cache key by default instead of only using the first argument.
Templating¶
pydash doesn’t have
template(). See Templating for more details.