Re: [PATCH] Rewrite feature to render hg-to-git compatible with python2.x and 3.x
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 17, 2019, 22:35 UTC
- Message-ID
- <xmqqd0fy7dra.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <0102016d3f74d202-d5b32dd4-0098-4ad0-8ac7-5fde254f7796-000000@eu-west-1.amazonses.com>
Hervé Beraud <herveberaud.pro@gmail.com> writes:
Show 7 quoted lines
> Rewrite features that are no longer supported (or recommended) > in Python 3 in the script so that it can be used with both > Python 2 and 3, namely: > > - print is not a statement; use print() function instead. > - dict.has_key(key) is no more; use "key in dict" instead. > - map(lambda ..., collection) is not liked; use list comprehension.
The first two are must haves (iow, without them the code would not work with Py3), but the last one sounds like a mere preference. Is there some authoritative source we can quote (e.g. "PEPx says that we should prefer X over Y")?
Show 7 quoted lines
> These changes introduce a syntaxe compatible with the both versions of > python. > > Python 2 is EOL at the end of 2019, the major part of distros > and systems now come with python 3 is the default version so > these address the situation to render this script compatible with > the latest versions of python.
The explanation looks vaguely familiar. I would have placed the background first, and then description of what is done next, perhaps like:
Python 2 is EOL at the end of 2019, many distros and systems now
come with python 3 as their default version. Rewrite features that are no longer supported (or recommended)
in Python 3 in the script so that it can be used with both
Python 2 and 3, namely: - print is not a statement; use print() function instead.
- dict.has_key(key) is no more; use "key in dict" instead.
- map(lambda ..., collection) is not liked; use list comprehension.to make it even easier to read without unnecessary repetition, but what you wrote is clear enough already.
The patch text looked clearly done. Nice.