git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Hervé BeraudNext: Junio C Hamano
Message 7 of 11 in “make hg-to-git compatible with python2.x and 3.x”
  1. make hg-to-git compatible with python2.x and 3.xHervé Beraud, Feb 15, 2018
  2. Junio C HamanoFeb 15, 2018
  3. make hg-to-git compatible with python2.x and 3.xHervé Beraud, Feb 20, 2018
  4. Junio C HamanoFeb 20, 2018
  5. Junio C HamanoFeb 20, 2018
  6. Rewrite feature to render hg-to-git compatible with python2.x and 3.xHervé Beraud, Sep 17, 2019
  7. Junio C HamanoSep 17, 2019
  8. Junio C HamanoSep 17, 2019
  9. hg-to-git: make it compatible with both python3 and python2Hervé Beraud, Sep 18, 2019
  10. Junio C HamanoSep 18, 2019
  11. hg-to-git: make it compatible with both python3 and python2Hervé Beraud, Sep 18, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.