News for hackers. Stuff that matters.
Re:Learning Go as a Python Developer: The Good and the Bad by thayne on Monday July 18, 2022 @10:52PM (#32146990)
An example where I have wanted this many times before it existed is in something like:

while (n := s.read(buffer)) != 0:

    #do something with first n bytes of buffer
Without the walrus operator you either have to duplicate the read operation before the loop and at the end of the loop, or use while True with a break if n is zero. Both of which are ugly IMO.

There are no comments on this comment yet.