Minor nitpick: Maybe consider reordering the conditions.

```python
if (not isinstance(w, int)) or (w <= 0) or (w%2 == 0):
```

Alternatively, if `w > 0` and `w%2 == 0`, evaluate to `True` does it matter that it's an int?