[Python-Dev] Please reject or postpone PEP 526 (original) (raw)
Guido van Rossum guido at python.org
Fri Sep 2 15:33:43 EDT 2016
- Previous message (by thread): [Python-Dev] Please reject or postpone PEP 526
- Next message (by thread): [Python-Dev] Please reject or postpone PEP 526
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Sep 2, 2016 at 10:47 AM, Steve Dower <steve.dower at python.org> wrote:
"I'm not seeing what distinction you think you are making here. What distinction do you see between:
x: int = func(value) and x = func(value) # type: int" Not sure whether I agree with Mark on this particular point, but the difference I see here is that the first describes what types x may ever contain, while the latter describes what type of being assigned to x right here. So one is a variable annotation while the other is an expression annotation.
But that's not what type comments mean! They don't annotate the expression. They annotate the variable. The text in PEP 484 that introduces them is clear about this (it never mentions expressions, only variables).
Personally, I prefer expression annotations over variable annotations, as there are many other languages I'd prefer if variable have fixed types (e.g. C++, where I actually enjoy doing horrible things with implicit casting ;) ).
Variable annotations appear to be inherently restrictive, so either we need serious clarification as to why they are not, or they actually are and we ought to be more sure that it's the direction we want the language to go.
At runtime the variable annotations are ignored. And a type checker will only ask for them when it cannot infer the type. So I think we'll be fine.
-- --Guido van Rossum (python.org/~guido)
- Previous message (by thread): [Python-Dev] Please reject or postpone PEP 526
- Next message (by thread): [Python-Dev] Please reject or postpone PEP 526
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]