Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

FWIW, I should have add a bit more explanation.  The logic for ABCs 
instantiation is roughly:

    if any(method.is_abstract() for method in dir(cls)):
        raise TypeError('I refuse to instantiate')
    inst = instantiate(cls)

The edge case for any() is to default to False for an empty input sequence and 
this logic applies to ABCs as well.

Alternatively, you can think of the it as using all() style logic, "instantiate 
this class only if all of the methods are non-abstract even if the class has no 
methods at all".  The edge case for all() is that it returns True for an empty 
input.

Another way of describing the logic is that the normal case for instantiating a 
class is to create an instance unless there is still work to be done (as 
evidenced by the presence of one or more abstract methods).  

The abstract methods are essentially a todo list for subclassers.  If there are 
no open todos (even if there were never any todos), instantiation can go 
forward -- "You can't build that building until you have all the permits, but 
there are no permit requirements in this case, so go ahead with the 
construction."

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32060>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to