3 ms·
Not a bad list. Feels like most of them should just be linter rules. I also found a few them don't really apply if you're using static types (which you really r
by IshKebab 5y ago
Not a bad list. Feels like most of them should just be linter rules. I also found a few them don't really apply if you're using static types (which you really really really should), e.g.
* Returning more than one variable type from function call: That's fine; the type checker will make sure you don't make a mistake.
* Asking for permission instead of forgiveness: Makes sense for the example given (`unlink`) but it is better to e.g. check types explicitly with `isinstance()` than to catch `TypeError`.
- ThePhysicist 5y agoYes absolutely, that book was written before type annotations made it into Python though.
- refactor_master 5y agoAsking for permission instead of forgiveness can easily become an anti-pattern in itself, because it allows lazy code that turns `if known type has expected property` into `try prodding this Any object, and catch where it blows up later`