On 07/08/2020 10:44 AM, Ethan Furman wrote:

So namespaced variables only...  is there a recommendation on handling global() 
and local() type variables?

Okay, some off-list discussion clarified that for me:

- easiest way is to use a guard


```
    def foo(x, spam):
        match x:
            case Point(p, q, context=c) if c == spam:
                # Match
```

If there's a bunch, then SimpleNamespace can be used:

```
    def foo(x, spam):
        L = SimpleNamespace(**locals)
        match x:
            case Point(p, q, context=L.spam):
                # Match
```

So there we have it -- two ways to do it!  ;-)

--
~Ethan~
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/RFFG4UDD4BGSYPS4YCFQ7ADDV773LPBR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to