[Python-Dev] [Python-checkins] r51458 - peps/trunk/pep-0000.txt peps/trunk/pep-0362.txt
Nick Coghlan
ncoghlan at gmail.com
Tue Aug 22 12:11:45 CEST 2006
brett.cannon wrote:
> Added: peps/trunk/pep-0362.txt
> +Relation With Other PEPs
> +========================
> +
> +"Keyword-Only Arguments [#pep-3102]_
> +------------------------------------
> +
> +If keyword-only parameters come into existence, the Parameter object
> +will require modification. A ``keyword_only`` attribute will be added
> +that holds a boolean representing whether the parameter is
> +keyword-only or not.
Why an extra attribute instead of using "x.position is None"? Unlike
default_value, None is not otherwise a legitimate value for the position
attribute.
> +Where should keyword-only parameters be stored in the Signature object?
> +-----------------------------------------------------------------------
> +
> +If PEP 3102 [#pep-3102]_ ends up being accepted, there is the
> +possibility that storing keyword-only parameters in a set instead of
> +in the ``parameters`` attribute of the Signature object makes more
> +sense. Since keyword-only parameters do not have any semantic meaning
> +in terms of their position within the signature, there is no direct
> +semantic gain in storing it in the parameter list.
> +
> +Storing keyword-only paramaters in a set makes it much more explicit
> +that keyword-only parameters have no inherent order. It does have the
> +drawback, though, that if one wants to process all parameters at once
> +they would need to perform extra work to make sure to go through both
> +the parameter list and set.
Throwing the keyword arguments in a set still loses information that was
present in the source code. Preserving the ordering in the signature object
means that the author of the function can control the order in which the
keyword arguments are displayed by introspection-based help utilities (e.g.
putting "more important" arguments first.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list