Maybe something like this may work:
```python
types = [x for x in ('ipv4', 'ipv6') if self.getattr(x)]
```