[Python-ideas] PEP 484 (Type Hints) -- first draft round

Steven D'Aprano steve at pearwood.info
Tue Jan 20 11:55:10 CET 2015

On Tue, Jan 20, 2015 at 07:12:33PM +1300, Greg Ewing wrote:

> But there are alternatives. We could borrow 'as'
> from a certain other language:
>   num_feathers as int = 0

Which language did you have in mind? Cobra uses that syntax:


Even though Cobra is inspired by Python, I think it makes some bad 
choices, and this is one of them. Python uses "as" for name binding:

    import spam as ham
    with ham() as eggs: 
except SomeError as err:

It would be inconsistent and confusing to introduce "as" for 

> Or exploit the fact that '{' following an identifier
> is currently undefined:
>   num_feathers {int} = 0

Now you're just making up random syntax :-)


More information about the Python-ideas mailing list