From mcarans at yahoo.co.uk  Thu Dec 15 10:45:40 2016
From: mcarans at yahoo.co.uk (Michael Rans)
Date: Thu, 15 Dec 2016 15:45:40 +0000 (UTC)
Subject: [Python-porting] Function annotation syntax for 2.7/3.5
 compatibility and pasteurize
References: <1989457548.6150811.1481816740700.ref@mail.yahoo.com>
Message-ID: <1989457548.6150811.1481816740700@mail.yahoo.com>

Hi,
Which is the correct way of doing function annotations that work in 2.7 and 3.5?https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-codeor
http://python-future.org/func_annotations.html#func-annotations
?
I have a feature request for pasteurize from Python Future - that it automatically convert Python 3.5 style function annotations to whatever is the correct format for 2.7. Is that possible?
Thanks for all the good work!
Cheers,Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20161215/3b8dd20a/attachment.html>

From brett at python.org  Fri Dec 23 11:17:31 2016
From: brett at python.org (Brett Cannon)
Date: Fri, 23 Dec 2016 16:17:31 +0000
Subject: [Python-porting] Function annotation syntax for 2.7/3.5
 compatibility and pasteurize
In-Reply-To: <1989457548.6150811.1481816740700@mail.yahoo.com>
References: <1989457548.6150811.1481816740700.ref@mail.yahoo.com>
 <1989457548.6150811.1481816740700@mail.yahoo.com>
Message-ID: <CAP1=2W4xUqz9viZbxWPe9yAzNbpqhG=y6V-pJxyJBTJMx=vWag@mail.gmail.com>

On Fri, 23 Dec 2016 at 05:50 Michael Rans via Python-porting <
python-porting at python.org> wrote:

> Hi,
>
> Which is the correct way of doing function annotations that work in 2.7
> and 3.5?
>
> https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code
> or
> http://python-future.org/func_annotations.html#func-annotations
> ?
>

The best ways is either the type comment you mention above or
https://www.python.org/dev/peps/pep-0484/#stub-files. The suggestion from
Future will keep the information in the same spot that Python 3 code
expects it to be, it won't work with tools like mypy. So if you're doing it
to access the info at runtime then the Future suggestion works, but if
 you're doing it for type checking you want the other ways (and you can
obviously combine approaches if you want everything :) ).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20161223/f395d111/attachment.html>