On Sun, Apr 22, 2018 at 3:13 PM, Steve Dower <steve.dower at python.org> wrote: > This example makes me want “if expr as name:” (same semantics as ‘with’, > and the name is always bound to the expression result regardless of > truthiness), but doesn’t move me on assignment expressions. > In reality there often are other conditions being applied to the match for which `if expr as name` is inadequate. The simplest would be something like if ...: <something> elif (m := re.match('(.*):(.*)', line)) and m.group(1) == m.group(2): <whatever> And the match() call may not even be the first thing to check -- e.g. we could have elif line is not None and (m := re.match('(.*):(.*)', line)) and m.group(1) == m.group(2): -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180422/2492a2ca/attachment.html>
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