Nitpicky: The "nicer" way to write if expressions like this is something like:

```
if ((toskip and localnm not in toskip) or
        (toinclude and localnm in toinclude) or (not toskip and not toinclude)):
    hascls = ....
```

The extra indent on the second line helps disambiguate the if expression from the code block after the if statement.