
Oct. 21, 2023
7:10 p.m.
On Sat, Oct 21, 2023 at 10:01 PM Chris Angelico <rosuav@gmail.com> wrote:
On Sat, 21 Oct 2023 at 21:57, Ram Rachum <ram@rachum.com> wrote:
What about an if with the match inside it?
if m := re.match(...): ...
That's one of the motivating examples behind the walrus after all.
I love that, but it mostly makes sense for "if there's a match do this, otherwise do that" where most cases fall into "I'm absolutely sure there's a match here and here's what we should do with that match", and when that "absolutely sure" fails, the proper way to deal with that is by raising an exception.