(original) (raw)
On 4/25/07, Josiah Carlson <jcarlson@uci.edu> wrote:
No, the ABC requirements are checked as soon as a module is imported (i.e., classes are checked at definition time not when an instance is created). I have been using my own ABC implementation for quite a while and it has repeatedly proven it's value when I create a new derived class and forget to implement a necessary method.
Again, I disagree. With metaclasses it is easy and useful to have checking at class definition (see http://web.mit.edu/\~emin/www/source\_code/py\_abc/abc.py for an example of what I mean). Generally I don't want static checking, but occasionally it is nice to have something like that and ABCs provide a good way to do that.
I'm not claiming that is the only benefit of ABCs. I'm just pointing out what I find to be a very useful feature of ABCs that I hope makes into python.
If your unit tests take hours to run, then you aren't going to get
anything useful from the ABC requirements for hours either (unless you
are pre-instantiating everything you are going to use during program
execution, in which case this could become your unittest).
No, the ABC requirements are checked as soon as a module is imported (i.e., classes are checked at definition time not when an instance is created). I have been using my own ABC implementation for quite a while and it has repeatedly proven it's value when I create a new derived class and forget to implement a necessary method.
Please remember that this isn't about Java style type checking and
verification during compilation. This is, strictly speaking, ABC
checking on object instantiation, method invocation, and possibly even
argument verification. This isn't the magic bullet you are looking for
(you'll have to go to one of those static typed languages for that).
Again, I disagree. With metaclasses it is easy and useful to have checking at class definition (see http://web.mit.edu/\~emin/www/source\_code/py\_abc/abc.py for an example of what I mean). Generally I don't want static checking, but occasionally it is nice to have something like that and ABCs provide a good way to do that.
I'm not claiming that is the only benefit of ABCs. I'm just pointing out what I find to be a very useful feature of ABCs that I hope makes into python.