[Python-Dev] pep 362 - 5th edition
Steven D'Aprano
steve at pearwood.info
Wed Jun 20 10:15:57 CEST 2012
On Tue, Jun 19, 2012 at 12:38:38PM -0400, Yury Selivanov wrote:
> > class Signature:
> > . . .
> > def equivalent(self, other):
> > "compares two Signatures for equality (ignores parameter names)"
> > . . .
>
> I don't think that comparing signatures will be a common operation,
> so maybe we can postpone adding any additional methods for that?
I think it may be. Consider callback functions: the caller may wish to
check that the callback function takes the right number of positional
arguments, but without caring whether those arguments are given any
particular name.
Checking for compatible signatures is a little more subtle than just
ignoring names. For example, keyword-only arguments need to always be
compared by names. Also, you might want to ignore optional arguments
with defaults, or at least _private optional arguments.
I think equality should be strict, including names, and we should defer
any decision about less-strict comparisons until 3.4, when we'll have
more solid use-cases for it.
I guess that's a long-winded way of saying +1 :)
--
Steven
More information about the Python-Dev
mailing list