In the second example, you provide 3 arguments: file name, mode, and dictionary ( kwargs ). But Python expects: 2 formal arguments plus keyword arguments.
By prefixing the dictionary "**", you unpack the kwargs dictionary into keyword arguments.
A dictionary (type dict ) is the only variable containing key-value pairs.
"Keyword arguments" are the parameters of the key-value method.
Any dictionary can be unpacked into the arguments of the keyword, prefix it with ** during a function call.
gecco Mar 26 2018-12-12T00: 00Z
source share