I come from a background in static languages. Can someone explain (ideally through example) the real world advantages of using **kwargs over named arguments
Here's an example, I used in CGI Python. I created a class that took **kwargs to the __init__ function. That allowed me to emulate the DOM on the server-side with classes:
document = Document()
document.add_stylesheet('style.css')
document.append(Div(H1('Imagist\'s Page Title'), id = 'header'))
document.append(Div(id='body'))
The only problem is that you can't do the following, because class is a Python keyword.
Div(class = 'foo')
The solution is to access the underlying dictionary.
Div(**{'class':'foo'})
I'm not saying that this is a "correct" usage of the feature. What I'm saying is that there are all kinds of unforseen ways in which features like this can be used.