Any simple python package providing dict merge?

pepper_chico

I want to do something like this:

merge({'a': 1}, {'b': 2})

and get a return of {'a': 1, 'b':2}.

  1. I don't want to use .update(), which sadly doesn't return the updated or a new dict, just None (why?.....).
  2. Since I know .update(), I could write a 3 line function for this. I don't, I just want an already existing/known package that do this kind of job in a simple way.

EDIT

This edit is just to explain the lovely SO users that this is not a duplicate of How to merge two Python dictionaries in a single expression? and hence the chosen answer is unrelated with any of the answers provided in the candidate duplicate.

Simeon Visser

The package dictmerge can merge dictionaries.

As of Python 3.5 you can merge dictionaries without an additional package:

>>> d1 = {'a': 1}
>>> d2 = {'b': 2}
>>> {**d1, **d2}
{'b': 2, 'a': 1}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Sorting and merge values of a python dict

From Dev

Simple Merge Sort bug in Python

From Dev

Simple Merge Sort bug in Python

From Java

How to merge the multiple lists into a dict with Python?

From Dev

Best way to aggregate a simple dict in Python

From Dev

Best way to aggregate a simple dict in Python

From Dev

Dict merge in a dict comprehension

From Dev

Python adding/updating dict element of any depth

From Dev

iPython debugger not providing any insight

From Dev

Permissions when creating a simple Python package for pip

From Dev

Is there any way to see all the versions for a python package?

From Dev

Is there any package to read table from file in python

From Dev

are there any simple negation boolean operator in python?

From Dev

Install programmatically a NPM package providing its version

From Java

go mod: cannot find module providing package

From Dev

Providing a customized config file for another package

From Dev

How to change value for item in a list of dict in python in a simple way?

From Dev

How to change value for item in a list of dict in python in a simple way?

From Dev

Is there any way to use get with object instead of dict in python

From Dev

What's the golang equivalent of converting any JSON to standard dict in Python?

From Dev

Check if dict key is a substring of any other element in the dictionary in Python?

From Dev

Can't install any python package from the python command prompt

From Dev

How to merge list to become string without adding any character in python?

From Dev

Dict into Dict Python

From Dev

Is there any way to manually add a "package" (eg. Python) to a group?

From Dev

Couldn't find any package by glob 'Python-3.7.0'

From Dev

How to encode stream of bits (not bytes) in Python - is any simple module for it?

From Dev

How to find a Fedora package providing a dependency I need?

From Dev

How to remove a package providing a service without stopping the service?

Related Related

  1. 1

    Sorting and merge values of a python dict

  2. 2

    Simple Merge Sort bug in Python

  3. 3

    Simple Merge Sort bug in Python

  4. 4

    How to merge the multiple lists into a dict with Python?

  5. 5

    Best way to aggregate a simple dict in Python

  6. 6

    Best way to aggregate a simple dict in Python

  7. 7

    Dict merge in a dict comprehension

  8. 8

    Python adding/updating dict element of any depth

  9. 9

    iPython debugger not providing any insight

  10. 10

    Permissions when creating a simple Python package for pip

  11. 11

    Is there any way to see all the versions for a python package?

  12. 12

    Is there any package to read table from file in python

  13. 13

    are there any simple negation boolean operator in python?

  14. 14

    Install programmatically a NPM package providing its version

  15. 15

    go mod: cannot find module providing package

  16. 16

    Providing a customized config file for another package

  17. 17

    How to change value for item in a list of dict in python in a simple way?

  18. 18

    How to change value for item in a list of dict in python in a simple way?

  19. 19

    Is there any way to use get with object instead of dict in python

  20. 20

    What's the golang equivalent of converting any JSON to standard dict in Python?

  21. 21

    Check if dict key is a substring of any other element in the dictionary in Python?

  22. 22

    Can't install any python package from the python command prompt

  23. 23

    How to merge list to become string without adding any character in python?

  24. 24

    Dict into Dict Python

  25. 25

    Is there any way to manually add a "package" (eg. Python) to a group?

  26. 26

    Couldn't find any package by glob 'Python-3.7.0'

  27. 27

    How to encode stream of bits (not bytes) in Python - is any simple module for it?

  28. 28

    How to find a Fedora package providing a dependency I need?

  29. 29

    How to remove a package providing a service without stopping the service?

HotTag

Archive