[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

Michael Selik mike at selik.org
Fri Jun 22 13:02:45 EDT 2018

On Fri, Jun 22, 2018 at 8:09 AM Antoine Pitrou <solipsis at pitrou.net> wrote:

> Thank you.  Personally, I'd like to see feedback from
> educators/teachers after they take the time to read the PEP and take
> some time to think about its consequences.

I've started testing the proposed syntax when I teach. I don't have a large
sample yet, but most students either dislike it or don't appreciate the
benefits. They state a clear preference for shorter, simpler lines at the
consequence of more lines of code. This may partially be caused by the
smaller screen real estate on a projector or large TV than a desktop

My intuition is that one strength of Python for beginners is the relative
lack of punctuation and operators compared with most other languages. This
proposal encourages denser lines with more punctuation. Because of the
order of operations, many uses of ``:=`` will also require parentheses.
Even relatively simple uses, like ``if (match := pattern.search(data)) is
not None:`` require doubled parentheses on one side or the other. Beginners
are especially prone to typographical errors with mismatched parentheses
and missing colons and get easily frustrated by the associated syntax

Given the following options:


    if (row := cursor.fetchone()) is None:
        raise NotFound
    return row


    row = cursor.fetchone()
    if row is None:
        raise NotFound
    return row


    if (row := cursor.fetchone()) is not None:
        return row
    raise NotFound


    row = cursor.fetchone()
    if row is not None:
        return row
    raise NotFound

The majority of students preferred option B. I also tested some regex match
examples. Results were similar.

> My main concern is we're introducing a second different way of doing
> something which is really fundamental.

The few students who like the proposal ask why it requires creating a new
operator instead of repurposing the ``=`` operator.

I'll reserve my personal opinions for a different thread.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180622/d5d6c5a1/attachment.html>

More information about the Python-Dev mailing list