I’m thinking of using **kwargs in an unusual way: as data provider and not as overloading substituting tool. In this way all keyword arguments should be of one type, for example specifically formed tuple, and no way else. In example:
class SomeClass(object):
'''All **kwargs should be in ("string", 1, True) form'''
def __init__(self, some_param, **kwargs):
self.param = some_param
for arg in kwargs.itervalues():
if not isinstance(arg[0], str):
...
self.some_dict = kwargs
Is it OK to do so? I feel… strange, it seems uncanonical.
See what the
dictconstructor does in Python:Also a “creative” use of keyword arguments. If this works for a standard type, and makes sense in your application, go for it.