[Python-ideas] Short form for keyword arguments and dicts
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Jun 26 10:51:45 CEST 2013
Andrew Barnert wrote:
> Notice that in this case, you don't actually need to pull out font and pass
> it along:
>
> def __init__(self, text = "Hello", **kwds): default_size =
> calc_default_size(text, kwds.get('font', system_font))
> Widget.__init__(self, size = default_size, **kwds)
That's what I ended up doing in many cases. But using get()
with a constant name has something of a nasty whiff about it
as well.
> I think the issue isn't how many passed-on arguments you have, but how many
> you're peeking at.
Yes, that's what I meant.
--
Greg
More information about the Python-ideas
mailing list