[Python-Dev] Common subset of python 2 and python 3

Markus Unterwaditzer markus at unterwaditzer.net
Thu Jan 16 13:52:18 CET 2014


On Wed, Jan 15, 2014 at 01:22:44PM +0100, "Martin v. Löwis" wrote:
> Am 12.01.14 18:39, schrieb Nachshon David Armon:
> >>> I propose that this new version of python use the python 3 unicode model.
> >>> As the version of python will be fully compatible with both python 2 and
> >>> with python 3 but NOT necsesarily with all existing code in either. It is
> >>> designed as a porting tool only.
> 
> I don't think that it is possible to write an interpreter that is fully
> compatible for all it accepts. Would you think that the program
> 
> print(repr(2**80).endswith("L"))
> 
> is in the subset that should be supported by both Python 2 and Python 3?

IMO Python 2 and 3 do have this part in common when you talk about valid syntax
and available methods and functions, but not in terms of behavior. I think a
new proposed Python version should simply crash on your example.

I'm kind-of playing devil's advocate here because i agree with previous posters
that such a Python version is unneccessary with tox and "python2 -3"

> 
> Notice that it prints "True" in Python 2 and "False" in Python 3. So if
> this common-version interpreter *rejects* the above program, which
> operation (**, repr, endswith) would you want to ban from subset?

Warnings about using certain string methods on repr() might be a neat thing to
add to "python -3" or static analysis tools.

> 
> Regards,
> Martin
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/markus%40unterwaditzer.net



More information about the Python-Dev mailing list