On 2021-10-27 19:05:52 +1100, Chris Angelico wrote: > On Wed, Oct 27, 2021 at 6:00 PM Antoon Pardon <[email protected]> wrote: > > while (a, b) := next_couple(a,b)[-1]: > > ... [...]
> I'm not sure that it's much of a use-case; isn't it an infinite loop as
> written?
>
> And that's the problem. With multiple-assignment, the overall value is
> going to be the tuple, so you then have to add extra parentheses and
> subscripting to get what you want to check.
Right. I think for that you would want something like what Go does in
if:
if [assignment-statement ;] condition {
statements
}
Then you could write
while a, b = next_couple(a,b); b:
...
That doesn't even need the walrus operator.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | [email protected] | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
