On 17May2018 10:33, Steven D'Aprano firstname.lastname@example.org wrote:
On Wed, May 16, 2018 at 08:02:47PM +0100, MRAB wrote:
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.
That would be a serious PITA for modules which have to work with more than one version of Python.
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 email@example.com