A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-February/002142.html below:

[Python-Dev] final note on LANL syntax suggestions

[Python-Dev] final note on LANL syntax suggestionsgvwilson@nevex.com gvwilson@nevex.com
Wed, 9 Feb 2000 10:28:35 -0500 (EST)
Just to wrap up this thread (as if): a couple of people have pointed out
that two of the suggestions that came up w.r.t. Python syntax are really
about eliminating need for assignment-as-an-operator:

    do:
      line = readline()
    while line:
      print line

gets rid of a need for:

    while (line = readline()):
      print line

without the confusing-for-newcomers:

    while 1:
      line = readline()
      if not line: break
      print line

and the generalized case statement:

    if x is:
      expr1, expr2:
        x is the result of expr1 or expr2
      expr3:
        x is the result of expr3
      else:
        x is undefined or None

does:

    if ((x = expr1) or (x = expr2)):
      code using x
    elif x = expr3:
      code using x
    else:
      code

(Don't know what other people's experience is, but this comes up a lot in
my code when I'm doing Awk-style coding, i.e. when RE matching drives
execution.) Looking through some C++ code I wrote last year, these two
cases (loop control and capturing successful conditions) account for at
least three quarters of my uses of assignment-as-operator.

My thanks to people for pointing this out,
Greg




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4