News for hackers. Stuff that matters.
Re:Pattern matching accepted for Python by coldtea on Tuesday February 09, 2021 @09:42PM (#26085215)
Couldn't they have used "case" and "capture" clauses instead?

  match status:
     case not_found:
         return "Not found"
     capture success_code:
         return "Returned success code: %s" % success_code
or the "_ as x" or a myriad other ways to make capture explicit...
Re:Pattern matching accepted for Python by ben509 on Tuesday February 09, 2021 @11:17PM (#26085695)
A separate statement doesn't compose with complex patterns. I'd prefer always requiring the walrus operator to capture:

    match response:
      case (not_found, msg := _):
        return f"Not found: {msg}"
      case (error, "No swizzle available"):
        return "We lack swizzle. :-("
      case pair := (_, "Swizzle"):
        log(f"Unexpected swizzle: {pair}")
        return f"Swizzle?"
      case ((code := _), _):
        return f"Success: {code}"