[Python-Dev] PEP 572: Assignment Expressions (original) (raw)
Chris Barker chris.barker at noaa.gov
Thu Apr 19 18:59:59 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 19, 2018 at 5:45 AM, Nick Coghlan <ncoghlan at gmail.com> 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
Chris.Barker at noaa.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180419/db6c359d/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]