[Python-ideas] Code version evolver

Steven D'Aprano steve at pearwood.info
Mon Mar 11 19:25:03 EDT 2019

On Mon, Mar 11, 2019 at 09:38:21PM +0100, francismb wrote:
> Hi,
> I would like to discuss on the idea of a code (minor) version
> evolver/re-writer (or at least a change indicator). Let's see one wants
> to add a feature on the next version and some small grammar change is
> needed, then the script upgrades/evolves first the current code and then
> the new version can be installed/used.

What you want this "version evolver" to do might be clear to you, but it 
certainly isn't clear to me. I don't know what you mean by evolving the 
current code, but I'm guessing you don't mean genetic programming.


I don't know who you expect is using this: the Python core developers 
responsible for adding new language features and changing the grammar, 
or Python programmers.

I don't know what part of the current code (current code of *what*?) is 
supposed to be upgraded or evolved, or what you mean by that. Do you 
mean using this to add new grammatical features to the interpreter?

Do you mean something like 2to3? Something which transforms source code 
written in Python?


> Something like:
> >> new-code = python-next('3.7', current-code)
> >> is-python-code('3.8', new-code)
> >> True
> How hard is that? 

How hard it is to get the behaviour shown? Easy!

def python_next(version, ignoreme):
    x = float(version)
    return "%.1f" % (x + 0.1)

def is_python_code(target, version):
    return target == version

How hard is it to get the behaviour not shown? I have no idea, since I 
can't guess what these functions do that you don't show.

If you want these functions to do more than the behaviour you show, 
don't expect us to guess what they do.

> or what is possible and what not?
> where should it happen? on the installer?

Absolutely no idea.


More information about the Python-ideas mailing list