
On Thu, Sep 23, 2010 at 5:39 PM, Antoine Pitrou <solipsis@pitrou.net> wrote:
On Thu, 23 Sep 2010 16:37:21 +0200 Tarek Ziadé <ziade.tarek@gmail.com> wrote:
The problem is that the implemented method could have a different list of arguments and will eventually fail.
Using inspect, we could check in __subclasshook__ that the arguments defined are the same than the ones defined in the abstractmethod.-- the name and the ordering.
I don't think we should steer in the type checking direction. After all, the Python philosophy of dynamicity (dynamism?) is articulated around the idea that checking types "ahead of time" is useless. IMO, ABCs should be used more as a convention for documenting what capabilities a class claims to expose, than for type checking.
I think it goes further than documentation at this point. ABC is present and used in the stdlib, not the doc. So asking a class about its capabilities is a feature we provide for third-party code. Also, not sure what you mean about the "ahead of time", but ABCs can be used with issubclass() to check that an object quacks like it should. This is not opposed to dynamicity.
(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. And if it is so, there's no point checking them in that case. So it should definitely be something optional. Regards, Tarek
Regards
Antoine.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas
-- Tarek Ziadé | http://ziade.org