```if filename:```

You don't need to explicitly check for None.