Guido van Rossum <[email protected]> added the comment:
Hm. Shantanu's list shows that the next thing we should make usable without
importing typing is Any. (I haven't any idea how to do that other than just
making it a builtin.) But after that we should definitely tackle Callable, and
the obvious way to do it is to make callable indexable. But does that mean it
has to be a type? I don't think so -- it just has to be an object whose class
defines both __call__ and __getitem__. Pseudo code:
class callable:
def __call__(self, thing):
return hasattr(thing, "__call__")
def __getitem__(self, index):
# returns a types.GenericAlias instance
# (or a subclass thereof)
I honestly don't think that we should support isinstance(x, callable) even if
some people think that that should work.
In any case, we should first answer the questions that are still open for issue
42195 -- what should __args__ for [cC]allable[[int, int], str] be? (int, int,
str) or ((int, int), str) or ([int, int], str) or (Tuple[int, int], str) are
all still on the table. Please refer to that issue.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42102>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com