Use `getattr` with default instead of `if hasattr/else`

Seems simpler. That's all.