Specifying Python version

Instead of verbatim identifiers, how about a special comment giving the Python version in which the file was written? There could then be a tool similar to 2to3 that converts the file to a more recent version of Python that might have new reserved words. In most cases the new file would merely be a copy of the original, but with an updated Python version.

On 17May2018 10:33, Steven D'Aprano <steve@pearwood.info> wrote:
It also feels rather fragile. Though I'm having a little trouble formulating a concrete example, I just feel like this is the kind of thing that is easily mangled. For example in a revision control merge (pull new change from branch using older Python, whose older Python got slightly changed in the special comment - in the diff the special comment looks new, easy to accidentally roll over the target branch whose special comment has been updated: main branch: # ##pyver 3.3## maintenance branch: # ##pyver 2.4## maintenance branch: update to # ##pyver 2.5## and add a feature or fix main branch: merge changeset from maintenance, tread on the "3.3" with "2.5" Cheers, Cameron Simpson <cs@cskk.id.au>

It's in the same spirit as what I proposed in my answer to Guido's crazy idea, but set at a different level (in code instead of in setup.py in my proposal). I think it belongs to the same discussion, so I'm copying it here (sorry for the inconvenience if you already read it there): Le 16/05/2018 à 11:22, Brice Parent a écrit :
-Brice Le 16/05/2018 à 21:02, MRAB a écrit :

On 17May2018 10:33, Steven D'Aprano <steve@pearwood.info> wrote:
It also feels rather fragile. Though I'm having a little trouble formulating a concrete example, I just feel like this is the kind of thing that is easily mangled. For example in a revision control merge (pull new change from branch using older Python, whose older Python got slightly changed in the special comment - in the diff the special comment looks new, easy to accidentally roll over the target branch whose special comment has been updated: main branch: # ##pyver 3.3## maintenance branch: # ##pyver 2.4## maintenance branch: update to # ##pyver 2.5## and add a feature or fix main branch: merge changeset from maintenance, tread on the "3.3" with "2.5" Cheers, Cameron Simpson <cs@cskk.id.au>

It's in the same spirit as what I proposed in my answer to Guido's crazy idea, but set at a different level (in code instead of in setup.py in my proposal). I think it belongs to the same discussion, so I'm copying it here (sorry for the inconvenience if you already read it there): Le 16/05/2018 à 11:22, Brice Parent a écrit :
-Brice Le 16/05/2018 à 21:02, MRAB a écrit :
participants (4)
-
Brice Parent
-
Cameron Simpson
-
MRAB
-
Steven D'Aprano