Use `isinstance` instead:

```python
if not isinstance(subfolders, list):
```

Or if you want to be a little more forgiving on the type:

```python
import collections
...
if not isinstance(subfolders, collections.Iterable):
```