[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484

Paul Moore p.f.moore at gmail.com
Wed Aug 3 16:54:39 EDT 2016


On 3 August 2016 at 19:01, Guido van Rossum <guido at python.org> wrote:
> On Wed, Aug 3, 2016 at 10:29 AM, Paul Moore <p.f.moore at gmail.com> wrote:
>> On 3 August 2016 at 17:26, Guido van Rossum <guido at python.org> wrote:
>>> But here you're thinking with your runtime hat on
>>
>> Yep, that's the mistake I was making. Thanks for clarifying.
>>
>> I've yet to actually use a type checker[1], so I'm still not used to
>> thinking in terms of "typecheck-time" behaviour.
>
> That's unfortunate -- the feature I'm developing here is only of
> interest to people using a type checker, and the many details of what
> it should look like and how it should work will benefit most from
> feedback from people who have actually dealt with the existing way of
> declaring variables.

Understood. Mostly I'm keeping out of it - I chimed in because I
(mistakenly) thought the way of declaring instance variables clashed
with a non-(typing)-expert's understanding of what was going on
(defining a class variable which is used as a fallback value if
there's no instance variable of the same name). I still think the
notation could be confusing, but the confusion can be fixed with
documentation, and I'm happy to propose fixes for documentation when I
finally get round to using the feature.

Sorry for the noise.

>> [1] Off-topic, but I'm not sure if type annotations are powerful
>> enough (yet) to track bytes vs str sufficiently to help with resolving
>> Python 2 -> Python 3 string handling errors. When I get a chance to
>> confirm that's possible, I definitely have some candidate codebases
>> I'd like to try my hand with :-)
>
> Not yet, but we're working on it. See
> https://github.com/python/typing/issues/208

Great :-)

Paul


More information about the Python-ideas mailing list