Just noting some real code I typed today where `given` works great if
it allows unpacking syntax, and assignment expressions don't:

    while True:
        head, matched, s = s.partition(sep)
        if not matched:
            break

Using `given`:

     while matched given head, matched, s = s.partition(sep):

Typing "matched " twice still sucks, though;-)

It doesn't work as well with assignment expressions even if they were
(re)generalized to allow unpacking syntax.  In this specific case, I'd
keep the original loop-and-a-half rather than do:

    while (t := s.partition(sep})[1]:
        head, matched, s = t

With unpacking syntax restored, same answer:

    while (head, matched, s := s.partition(sep})[1]:

or
    while [(head, matched, s := s.partition(sep}), matched][-1]:

to combine the worst annoyances of everything and add another ;-)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to