Re:Pattern matching accepted for Python
by bobbylarrybobby on Wednesday February 10, 2021 @09:54PM
(#26097727)
You are (sadly) correct. The latter example checks that the type of `event.get()` is a Click, then that it has a `.position` attribute that be restructured into a two-element tuple `(x,y)`. It's equivalent to `ev = event.get(); if isinstance(ev, Click): (x,y) = ev.position`
What I still don't understand is: does the new syntax magically do this to a user-defined class? i.e. if I say
vs those identical expressions, for the same value of Click, have widely different semantics?edit: typo fix