[Python-Dev] arguments policy: **kwargs.pop()
Chris Barker
chris.barker at noaa.gov
Fri Apr 11 21:50:10 CEST 2014
On Thu, Apr 10, 2014 at 7:12 PM, Christian Tismer <tismer at stackless.com>wrote:
> Then I rather often see things like this:
>
> class someclass(object):
> # note that there is no comment about argument destruction...
>
> def __init__(self, **kwargs):
> first_arg = kwargs.pop('option_1', somedefault)
> ...
> nth_arg = kwargs.pop('option_n', somedefault')
> ...
>
While it's been clarified that this isn't dangerous, I find it to be a
really annoying style, as you've lost the opurtuniyt to docuemnt somethign
in the signature. Is:
def __init__(self, option_1=some_default, option_n=some_default,
**kwargs):
first_arg = kwargs.pop('option_1')
nth_arg = kwargs.pop('option_n')
*that* much harder to write?
And many of these come with virtually no docstring, either.....
oh well,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140411/b8138009/attachment.html>
More information about the Python-Dev
mailing list