On Friday, February 5, 2016 at 9:08:45 AM UTC-8, Nathann Cohen wrote:
>
> > Yes, this is a more universal problem in the UI:
>
> I object. It is a *very* simple mistake that has a *very* simple solution:
>
> Any function that takes **kwargs as argument must:
> 1) Remove from kwargs all values it understands
> 2) Forward the remaining content of kwargs to a subfunction
>
> I suppose you meant to add a third rule
3) In any branch where a **kwargs -taking function does not call
another function it forwards the **kwargs argument to, it must raise an
error if any unrecognized kwargs are left.
Note that this solution comes as a fairly significant penalty: you end up
copying/modifying the kwargs argument *all the time*. Those are dictionary
mutations (note that if you received a **kwargs, you cannot mutate the
kwargs, since this is someone else's dictionary. You have to copy it).
That's why I mentioned low/zero overhead. It would be nice to avoid.
In other suggestions: not using **kwargs is in general not really
practical. Introducing a new keyword below now requires all levels above to
be modified. DRY afficionado's won't approve. Plus explicitly spelling out
all keywords loses possible advantages of passing on a **kwargs unmodified.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.