How about:

```
polynomial = isinstance(f, Expr) and f.is_polynomial()
```