Type hints like in PEP 484 work on all Python 3 versions, and something similar to your proposal is already supported on Python 2 [1].

[1]: https://mypy.readthedocs.io/en/latest/python2.html


On July 4, 2018 11:08:27 PM Shawn Chen <shawnchen1...@outlook.com> wrote:

Hello,

Here, I am proposing a change on python type annotation.

Python was born to be a simple and elegant language. However recent change has again introduce new incompatibility to python.

The PEP 484 is proposing a type hint which can annotate the type of each parameters. How ever code written in this format can not be run for python3.5 and below.

It is an exciting new feature to be able to know the data type from the code, But I am afraid this is not worth such a incompatibility.

Here I want to propose a new way of annotation in python as follows

def reportAge(name, age):
''' this a a greeting function and some other comment...
!str, int -> str
'''
    return name+' is ' + age


we can put the annotation in the comment block and use a symbol '!' or other symbol suitable to lead a annotation line.
the annotation should be positionally corresponding to the parameters.

Shawn

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10




----------
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to