[Python-ideas] ABC: what about the method arguments ?

Tarek Ziadé ziade.tarek at gmail.com
Thu Sep 23 19:51:35 CEST 2010

On Thu, Sep 23, 2010 at 6:32 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> This feature already exists, as you mention, using issubclass() or
> isinstance(). What you are asking for is a different feature: check that
> a class has an appropriate implementation of the advertised
> capabilities. Traditionally, this is best left to unit testing (or other
> forms of test-based checking).
> Do you have an use case where unit testing would not be appropriate for
> this?

Why are you thinking about unit tests  ? Don't you ever use
issubclass/isinstance in your programs ?

Checking signatures using ABC when you create a plugin system is one
use case for instance.

>> > (also, you'll have a hard time checking methods with *args or **kwargs
>> > parameters)
>> True, but I don't expect the ABC to define abstract methods with vague
>> arguments.
> It depends on the arguments. And the implementation could definitely use
> *args or **kwargs arguments, especially if it acts as a proxy.

Sure but ISTM that most of the time signatures are well defined, and
proxies lives in an upper layer.


More information about the Python-ideas mailing list