News for hackers. Stuff that matters.
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}"

There are no comments on this comment yet.