[Python-3000] Generic function PEP won't make it in time
emin.shopper at gmail.com
Thu Apr 26 00:32:35 CEST 2007
On 4/25/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 4/25/07, Emin.shopper Martinian.shopper <emin.shopper at gmail.com> wrote:
> > I think a bigger issue is whether to check at definition time or check
> > instantiation time. It seems to me the former has the benefit of
> > errors earlier and potentially saving time. I don't immediately see the
> > advantage of the latter (probably that is due to my lack of
> The advantage of waiting is that you can *have* (partially) abstract
> classes. So long as you never instantiate them directly (super calls
> are OK), everything is fine.
Good point. However, you can do this without precluding def time checks. For
example, you can have any class which has abstract methods not be forced to
satisfy parent ABC rules since it is still abstract, or you can provide
another way to mark the class as partially abstract (my initial
implemenation does this by having the partially abstract class inherit from
both the parent abstract class and the class that all abstract classes
You could reasonably argue that the benefit of def time enforcement is
outweighed by the need to do something special for a class that inherits
from an abstract base class but has no abstract methods itself.
If you want an earlier check, then just create an instance of your
> class at import time (or, alternatively, in your unit tests). If it
> can be created, it passed the test.
Yes, I could do that assuming that the inputs to the class __init__ method
can be constructed quickly. Personally, I would find it preferable to have
to do something slightly different for partially abstract classes with no
abstract methods, but I guess it's a matter of taste.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-3000