18 May
2015
18 May
'15
11:59 a.m.
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())
I think Alex means this: https://github.com/ambv/typehinting/issues/107 This could be really useful, for example: def fancy_instantiate(cls: Type[T]) -> T: ...