Automatic binding of **kwargs to variables

lbolognini at lbolognini at
Sun Oct 30 03:21:42 CET 2005

What do u think of the following? I could keep the form schema as
expected_form1_kwargs in a separate module and import * and wrap the
kwargs check done in the for loop in a function for use in the whole

The elif part is useful for checkboxes which are not passed by the
browser if they're not checked.

def foo(self, **kwargs)
    expected_form1_kwargs = [arg1, arg2]

    for name in kwargs:
        if name not in expected_form1_kwargs:
            raise ValueError, "Unrecognized keyword" + name
        elif name in expected_form1_kwargs not in kwargs.keys():

Thanks again everybody,

More information about the Python-list mailing list