kwargs is just a name and ** is use to unpack dictionaries (kew words argument )
NB: kwargs could be any name you like
Little bit about kwargs:
>>> def foo(**new_kwargs):
... print new_kwargs
...
>>> dic = { 'key' : 'value' }
>>> foo(**dic)
{'key': 'value'}
>>>
>>> foo(key='value')
{'key': 'value'}
>>>
>>> foo(dic)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: foo() takes exactly 0 arguments (1 given)
>>>
And :
If you want to see all the attributes and method for a particular object (even class is an object in python): Use dir built-in function
:
dir(...)
dir([object]) -> list of strings
And if you want to see any particular attributes is method or function, you can use callable
to check if they are callable:
>>> dir(dict)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__',
'__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__',
'__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items',
'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault',
'update', 'values', 'viewitems', 'viewkeys', 'viewvalues']
>>>
>>> callable(dict.keys)
True
>>>
>>> class foo(object):
... class_variable = 'Some String'
... def function():
... return 'Some String'
...
>>> dir(foo)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__',
'__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'__weakref__', 'class_variable', 'function']
>>>
>>> callable(foo.class_variable)
False
>>> callable(foo.function)
True
>>>
What ever you show extra in dir(foo) are from base class object
.