3 ms·
The loop can be written using This One Weird Trick that Walruses Hate: for foo in iter(partial(data.get, "foo"), None): handle_foo(foo) So I would onl
by ptx 5y ago
The loop can be written using This One Weird Trick that Walruses Hate:
for foo in iter(partial(data.get, "foo"), None):
handle_foo(foo)
So I would only use the walrus operator for the first example (the if statement), which even though it is exactly the same as doing it in two steps just feels nicer as a single step.