Re: [Python-Dev] PEP 572: Assignment Expressions

2018年4月19日 16:03:07 -0700

On Thu, Apr 19, 2018 at 5:45 AM, Nick Coghlan <[email protected]> wrote:
> * for the while loop use case, I think my discussion with Tim about
> tuple unpacking shows that the loop-and-a-half construct won't be
> going anywhere, so users would still end up needing to learn both
> forms (even for new code)
>
well, yes, but I've always found while awkward in the common case -- and
wanted a better way (maybe an until?).
using:
while True:
 ...
for a loop with a clear testable termination criteria always felt clunky.
Anyone recall the "canonical" way to loop through the lines of a file
before we had the file iterator?
while True:
 line = fp.readline()
 if not line:
 break
 do_stuff_with(line)
This is in fact, the only compeling use case for this to me -- maybe we
could make a way to do an assign and test in a while loop enhancement just
for that?
And no, I have no idea what that would look like -- I'm mostly joking.
So -1 on this -- though I agree -- great PEP Chris!
And -1, not -0 because I think this really would add one more complication
to a language that used to be so simple, and still is (and should be) used
a first programming language. I teach a lot of newbies, and I'm realy not
l;ooking forward to one more way to do assignement. It starts simpel enough:
x = something
binds the name, "x" the the object, 'something' is bound to (or a literal)
Then we get into:
 - multiple assignment
 - tuple unpacking (oops, sequence unpacking),
 - augmented assignment
 - oh, that works different depending on whether the object is mutable
We don't need any more.
-CHB
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[email protected]
_______________________________________________
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

Reply via email to