Curiosity question on signatures
Gonçalo Rodrigues
op73418 at mail.telepac.pt
Fri Mar 5 19:08:53 EST 2004
Hi all,
I just noticed the following fact:
>>> def f(arg):
... print "Arg is %s." % arg
...
>>> f(1)
Arg is 1.
>>> f(arg = 0)
Arg is 0.
Even "worse":
>>> def g(arg1, arg2):
... print "Args: %s, %s." % (arg1, arg2)
...
>>> g(arg2 = 9, arg1 = None)
Args: None, 9.
>>>
Does this "feature" of being able to treat positional arguments as
named arguments have any use? Does anybody make any use of it? Is
there any rationale on why it's in the language?
I'm asking this, because if we define equivalence of functions
signatures in the obvious way ("they accept the same calls") then
def f(arg):
....
def g(name):
....
don't have equivalent signatures because f can be called with (arg =
0) which does not work with g. It looks... wrong (maybe because what I
have in my mind is the mathematical concept of a function where named
arguments do not exist).
This is no big deal of course, just a curiosity.
With my best regards,
G. Rodrigues
More information about the Python-list
mailing list