[Python-3000] PEP3102 Keyword-Only Arguments; Signature (original) (raw)
Jim Jewett jimjjewett at gmail.com
Mon Aug 14 22:24:15 CEST 2006
- Previous message: [Python-3000] Bound and unbound methods
- Next message: [Python-3000] PEP3102 Keyword-Only Arguments; Signature
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 8/14/06, Steven Bethard <steven.bethard at gmail.com> wrote:
On 8/14/06, Guido van Rossum <guido at python.org> wrote: > I believe the PEP doesn't address the opposite use case: positional > arguments that should not be specified as keyword arguments.
...
It would be really nice in the example above to mark
selfin_call_as a positional only argument.
Would this have to be in the standard function prologue, or would it be acceptable to modify a function's Signature object?
As I see it, each argument can be any combination of the following:
positional
keyword
named
defaulted
annotatedI can see some value in supporting all 32 possibilities, but doing it directly as part of the def syntax might get awkward.
Most arguments are both positional and keyword. The bare * will support keyword-only, and you're asking for positional-only. (An argument which is neither positional nor keyword doesn't make sense.)
Today (except in extension code), an argument that isn't named only appears courtesy of *args or **kwargs.
Today, named + keyword <==> defaulted
Today, arguments are not annotated.
Would it be acceptable if functions contained a (possibly implicit) Signature object, and the way to get the odd combinations were through modifying that?
For example:
def unnamedargs(func):
for arg in func.Signature:
arg.name=None
return func... @unnamedargs def write(self, s):
-jJ
- Previous message: [Python-3000] Bound and unbound methods
- Next message: [Python-3000] PEP3102 Keyword-Only Arguments; Signature
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]