[Python-ideas] ABC: what about the method arguments ?
ziade.tarek at gmail.com
Thu Sep 23 17:08:03 CEST 2010
On Thu, Sep 23, 2010 at 4:54 PM, Daniel Stutzbach
<daniel at stutzbachenterprises.com> wrote:
> On Thu, Sep 23, 2010 at 9:37 AM, Tarek Ziadé <ziade.tarek at gmail.com> wrote:
>> The problem is that the implemented method could have a different list
>> of arguments and will eventually fail.
> A slightly different argument list is okay if it is more permissive. For
> example, the collections.Sequence ABC defines a count method with one
> parameter. However, the list implementation's count method takes one
> mandatory parameter plus two optional parameters. I'm not sure how easy it
> would be to detect a valid but more general signature.
Well, with inspect it's possible to see if the extra parameters have
defaults values, thus making calls without them still working.
> You might be interested in the related Issue 9731 ("Add ABCMeta.has_methods
> and tests that use it").
Ah... interesting.. has_methods could possibly have an option to check
for the signature
--will hack on that when I find some time--
> Daniel Stutzbach, Ph.D.
> President, Stutzbach Enterprises, LLC
Tarek Ziadé | http://ziade.org
More information about the Python-ideas