[Python-ideas] Type Hinting Kick-off
Guido van Rossum
guido at python.org
Thu Dec 25 20:42:34 CET 2014
More information about the Python-ideas mailing list
Thu Dec 25 20:42:34 CET 2014
- Previous message: [Python-ideas] Type Hinting Kick-off
- Next message: [Python-ideas] Type Hinting Kick-off
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Dec 25, 2014 at 6:43 AM, Steven D'Aprano <steve at pearwood.info> wrote: > 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? > I would not recommend that to anyone -- I find that use of "import ... as" is often an anti-pattern or a code smell, and in this case it would seem outright silly to fight the standard library's terminology (assuming typing.py defines Union). I don't know if mypy supports this (it's easy to try it for yourself though) but I do know it follows simple global assignments, known as type aliases, e.g. "foo = Iterator[int]". -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141225/6c137e53/attachment.html>
- Previous message: [Python-ideas] Type Hinting Kick-off
- Next message: [Python-ideas] Type Hinting Kick-off
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list