Was just adapting the content @asmeurer pointed me to.  But your example doesn't show how exclude changes the match.  How about

```
>>> a,b=symbols('a b',cls=Wild)
>>> (2*x**3*y).match(a*b)
{a_: 2*y, b_: x**3}
>>> a=Wild('a',exclude=[x,y])
>>> (2*x**3*y).match(a*b)
{a_: 2, b_: x**3*y}
```