Changes between Version 29 and Version 30 of CodingStandards
- Timestamp:
- 2014-10-10T15:57:56Z (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CodingStandards
v29 v30 43 43 * 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:}}}. 44 44 * 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. 45 46 === Miscellaneous === 47 48 * {{{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. 45 49 46 50 == Idioms == … … 165 169 self.backendtype = backendtype 166 170 }}} 167 .168 169 171 170 172 == Official Python Standards ==