[Python-ideas] PEP 484 (Type Hints) -- second draft
Cameron Simpson
cs at zip.com.au
Mon Mar 23 22:41:45 CET 2015
On 23Mar2015 04:55, Terry Reedy <tjreedy at udel.edu> wrote:
>On 3/23/2015 2:02 AM, David Foster wrote:
>>* It's a bit vague how local variables should be typed in the presence of
>> multiple assignments. Consider:
>>
>> ```
>> if x > 0:
>> root = sqrt(x) # type: int
>> else:
>> root = None
>> ```
>
>root = sqrt(x) if x > 0 or None # type: Union(int, None)
Should people need to reshape their code for this?
In the example above it is small, though less readable already.
But it scales very badly; what of a 4 way if etc? It moves from a bit less
readable to a nightmare.
Cheers,
Cameron Simpson <cs at zip.com.au>
Do not cross the oncoming lanes of death that are California's highways.
- SJ Mercury News
More information about the Python-ideas
mailing list