Automatic binding of **kwargs to variables
lbolognini at gmail.com
lbolognini at gmail.com
Sun Oct 30 01:38:59 EDT 2005
Alex Martelli wrote:
> I find this style of coding repulsive when compared to:
>
> def foo(arg1=None, arg2=None):
> print dict(arg1=arg1, arg2=arg2)
>
> I don't understand what added value all of those extra, contorted lines
> are supposed to bring to the party.
Hi Alex,
the thing is that I have about 30 parameters to pass to a method and I
wanted to have a cleaner way to deal with it than just declaring them
all as arguments: hence **kwargs and all that mess ;-)
I was thinking to declare the a list of valid and expected parameters
in a module and then import * and run my checks against it. Since this
stuff is being posted by a web form I also need to deal with checkbox
not being posted if not checked which lead me to:
for name in expected_form1_kwargs:
if name not in kwargs:
kwargs[name]=None
Lorenzo
More information about the Python-list
mailing list