2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-28 08:43:51 +00:00
bazel-skylib/docs/dicts_doc.md
Alexandre Rostovtsev 99ffbbf8a4
Prepare release 1.6.0 (#496)
And take the opportunity to reformat docs using a more modern Stardoc release
2024-04-24 17:40:06 -04:00

2.3 KiB
Executable file

Skylib module containing functions that operate on dictionaries.

dicts.add

dicts.add(dictionaries, kwargs)

Returns a new dict that has all the entries of the given dictionaries.

If the same key is present in more than one of the input dictionaries, the last of them in the argument list overrides any earlier ones.

This function is designed to take zero or one arguments as well as multiple dictionaries, so that it follows arithmetic identities and callers can avoid special cases for their inputs: the sum of zero dictionaries is the empty dictionary, and the sum of a single dictionary is a copy of itself.

PARAMETERS

Name Description Default Value
dictionaries Zero or more dictionaries to be added. none
kwargs Additional dictionary passed as keyword args. none

RETURNS

A new dict that has all the entries of the given dictionaries.

dicts.omit

dicts.omit(dictionary, keys)

Returns a new dict that has all the entries of dictionary with keys not in keys.

PARAMETERS

Name Description Default Value
dictionary A dict. none
keys A sequence. none

RETURNS

A new dict that has all the entries of dictionary with keys not in keys.

dicts.pick

dicts.pick(dictionary, keys)

Returns a new dict that has all the entries of dictionary with keys in keys.

PARAMETERS

Name Description Default Value
dictionary A dict. none
keys A sequence. none

RETURNS

A new dict that has all the entries of dictionary with keys in keys.