[Python-ideas] Type Hinting Kick-off
steve at pearwood.info
Thu Dec 25 15:43:35 CET 2014
On Wed, Dec 24, 2014 at 08:16:52PM -0800, Guido van Rossum wrote:
> On Wed, Dec 24, 2014 at 4:50 PM, Eugene Toder <eltoder at gmail.com> wrote:
> > Pragmatics:
> > 3. The names Union and Intersection are standard terminology in type
> > checking, but may not be familiar to many Python users. Names like
> > AnyOf and AllOf can be more intuitive.
> I strongly disagree with this. Python's predecessor, ABC, used a number of
> non-standard terms for common programming language concepts, for similar
> reasons. But the net effect was just that it looked weird to anyone
> familiar with other languages, and for the users who were a completely
> blank slate, well, "HOW-TO" was just as much jargon that they had to learn
> as "procedure". Also, the Python users who will most likely need to learn
> about this stuff are most likely library developers.
I presume that runtime name binding will be allowed, e.g.
from typing import Union as AnyOf
def spam(x: AnyOf[int, float])->str: ...
but not encouraged. (It's not that hard to learn a few standard names
like Union.) So the above would work at runtime, but at compile time, it
will depend on the specific linter or type checker: it will be a
"quality of implementation" issue, with simple tools possibly not
being able to recognise AnyOf as being the same as Union.
Is this what you have in mind?
More information about the Python-ideas