A few quarts in a function call?

I have a simple function called like this:

arbitrary_function(**kwargs1, **kwargs2, **kwargs3)

It seems to compile on my local installation (python 3.5.1), but throws a SyntaxError when I compile it on the docker using python 3.4.5.

I'm not too sure why this behavior is present. Are multiple quarts allowed? Do I have to combine them before moving on to a function? It is more convenient to transfer them individually, for example:

plot(**x_axis_params, **y_axis_params, **plot_params)

instead

params = dict()

for specific_param in [x_axis_params, y_axis_params, plot_params]:    
    params.update(specific_param)

plot(**params)
+4
source share
2 answers

This is a new feature introduced in Python 3.5. If you need to support Python 3.4, you basically stick to the loop update.

, dicts , , update, 3.5 +, . ( - {**kwargs1, **kwargs2, **kwargs3}.)

+1

PEP448 ( Python), collections.ChainMap:

from collections import ChainMap

plot(**ChainMap(x_axis_params, y_axis_params, plot_params))

ChainMap Python 3.3, docker.

0

Source: https://habr.com/ru/post/1650724/


All Articles