On 25/06/20 3:31 am, Taine Zhao wrote:
In your AND pattern example, you seem to envisage there being a Urlopen class whose __match__ method has the side effect of opening the URL.
This makes it much more than just a pattern to be matched, as it's also doing some of the work of your program. I would say this goes against the spirit of what the PEP proposes, which is that patterns should just be passive declarations of things to look for and should not have side effects.
That's not to say there are no uses for deconstructing the same object more than one way, but your case would be more persuasive if you could come up with a side-effect-free example.