If you restrict the idea to 'if' and 'while', Why not render this using the
existing 'as' form for binding names, already used with 'except' and 'with':
while learner.get(static_hint) as points:
learner.feed(f(points))
The equivalent for 'if' helps with the regex matching case:
if re.match(r"...") as m:
print(m.group(1))
I considered proposing these two forms in a PEP a few years ago, but never
got around to it. To my eye, they fit syntactically into the language
as-is, without introducing new symbols, operators or keywords, are
consistent with existing usage, and address two relatively common causes of
displeasing Python code.
Robert
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com