[Python-Dev] PEP 484 wishes
Guido van Rossum
guido at python.org
Mon May 18 01:50:22 CEST 2015
More information about the Python-Dev mailing list
Mon May 18 01:50:22 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 484 wishes
- Next message (by thread): [Python-Dev] PEP 484 wishes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, May 17, 2015 at 3:07 PM, Alex Grönholm <alex.gronholm at nextday.fi> wrote: > Looking at PEP 484, I came up with two use cases that I felt were not > catered for: > > 1. Specifying that a parameter should be a subclass of another > (example: Type[dict] would match dict or OrderedDict; plain "Type" would > equal "type" from builtins) > > I don't understand. What is "Type"? Can you work this out in a full example? This code is already okay: def foo(a: dict): ... foo(OrderedDict()) > > 1. Specifying that a callable should take at least the specified > arguments but would not be limited to them: Callable[[str, int, ...], Any] > > Case #2 works already (Callable[[str, int], Any] if the unspecified > arguments are optional, but not if they're mandatory. Any thoughts? > For #2 we explicitly debated this and found that there aren't use cases known that are strong enough to need additional flexibility in the args of a callable. (How is the code calling the callable going to know what arguments are safe to pass?) If there really is a need we can address in a future revision. -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150517/28d2bbdd/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 484 wishes
- Next message (by thread): [Python-Dev] PEP 484 wishes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list