[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484
Ethan Furman
ethan at stoneleaf.us
Mon Aug 1 17:49:12 EDT 2016
On 08/01/2016 02:40 PM, Chris Angelico wrote:
> On Tue, Aug 2, 2016 at 7:31 AM, Guido van Rossum wrote:
>> I'd like to address this in the future, and I think the most elegant
>> syntax would be to let you write these as follows:
>>
>> a: float = 0
>> b: List[int] = []
>> c: Optional[str] = None
>>
>> There are some corner cases to consider.
>
> Additional case, unless it's patently obvious to someone with more 484
> experience than I: what happens with chained assignment?
>
> a = b = c = 0
>
> Does each variable get separately tagged, or does one tag apply to all?
I would think each name would need to be typed:
a: int = b: int = c: int = 0
However, if somebody was doing typing from the get-go I would imagine they would do:
a, b, c: float
--
~Ethan~
More information about the Python-ideas
mailing list