Newsgroups: comp.lang.python
From: Demian Brecht <demianbre...@gmail.com>
Date: Sat, 06 Oct 2012 15:45:23 -0700
Local: Sat, Oct 6 2012 6:45 pm
Subject: Re: Are ABCs an anti-pattern?
On 12-10-05 12:58 PM, Trent Nelson wrote:
> I like them. In particular, I like that I can enumerate all the
As long as you have a common base class (which in your case is a > subclasses that happen to implement the ABC via the metaclass's > __subclasses__() method. requirement), then __subclasses__ works for introspecting child classes. It doesn't *really* have anything to do with abcs. > I also like that I can trust Python
Another way to read this is that you don't trust those using your code > not to instantiate a subclass of an ABC unless it meets all the > interface criteria I've stipulated. to be bright enough to understand what your code is doing and what it requires. In my mind, this seems to somewhat contradict the philosophy of "we're all consenting adults here". Whether you utilize interfaces or not, code should be documented. Your documentation would be responsible for laying out the expected interface (again, whether you're using the interfaces or not). Code would fail at some point if a requirement on an interface hasn't been filled. The *one* nice thing is that it'll error on import rather than execution time, but to me, if your code is unit tested, then all these things should be caught almost immediately anyway. From my experience (again, *only* talking about Python here), it seem Again, please don't misunderstand my intentions here. I'm not arguing Thanks for your the feedback so far.
-- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||