add athing in adict

[Imported from Trac: page CodingStandards, version 30]
zooko 2014-10-10 15:57:56 +00:00
parent 75c13f2475
commit de3edc1b09

@ -43,6 +43,10 @@ from allmydata.util.assertutil import _assert, precondition, postcondition
* Don't use the literals `True` or `False` in conditional expressions -- instead just write the expression which will evaluate to true or false. For example, write `if expr:` instead of `if expr == True:` and `if not expr:` instead of `if expr == False:`.
* Avoid relying on the fact that empty sequences, empty strings, empty dicts, `0`, and `None` are treated as false. Write `if len(items) == 0:`, `if thing is None:`, etc.
### Miscellaneous
* `athing in adict.keys()` can be replaced by `athing in adict`, which evaluates to the same boolean result, but is more succinct and more efficient at run-time.
## Idioms
### Preconditions and Assertions
@ -164,8 +168,6 @@ class BlockStore:
self.maintainertype = maintainertype
self.backendtype = backendtype
```
.
## Official Python Standards