The Principles
Python functions allow keyword arguments. For example this function:
def sub(a, b):
return a - b
can be called like this:
>>> sub(b=10, a=4)
-6
If you have the arguments in a dictionary:
>>> args = {'a': 4, 'b': 10}
you can use the **
syntax to achieve the same:
>>> sub(**args)
-6
This is called unpacking because the items in the dictionary are used individually as arguments.
Your Example
Your example is over complicated. This would work:
'{num} = {title}'.format(num=7, title='Strings')
No need for using **
and a dictionary. The format()
methods works like normal function and can be used with keyword arguments directly. The values 7
and Strings
are put into a dictionary just be taken out again immediately.