Hey @bharathinmail5419 welcomet to the forum!
This is making use of Python keyword unpacking. This allows you to pass keyword parameters to functions using a dictionary of key=value pairs.
When we call the execute_this_fn
we call it with the following …
execute_this_fn(**self.kwargs)
This unpacks the key=value pairs in the self.kwargs
dictionary, as keywords for the function. So for example, if we had the following dictionary
my_dict = {
'something': 3,
'another': 6,
}
and then called a function as follows…
my_function(**my_dict)
this would be the equivalent of …
my_function(something=3, another=6)
So, going back to the original example. We have a dictionary called kwargs
which holds keyword arguments. We add another entry to that dictionary called 'progress_callback'
which holds the function we’re going to call. That could be anything, but for example say we stored the print
function –
kwargs = {}
kwargs['progress_callback'] = print # Store the print function in this dictionary
If we then called our function with…
execute_this_fn(**kwargs)
That would be the equivalent of calling
execute_this_fn(progress_callback=print)
The value stored in the dictionary under progress_callback
is passed as an argument with that keyword to the function.