Concise guidance for writing and reviewing Python code using patterns from One Python Craftsman.
TopicGuidanceReferenceVariables and NamingDescriptive names, avoid implicit magic, keep variable scope closereferences/variables-and-naming.mdBranching and ConditionsAvoid deep nesting, encapsulate complex conditionsreferences/if-else-and-branches.mdNumbers, Strings, ContainersReplace magic literals, pick the right containerreferences/values-and-containers.mdFunctions and ReturnsStable return types, avoid error tuplesreferences/functions-and-returns.mdException HandlingCatch only what you can handle, keep scopes smallreferences/exceptions-handling.mdLoops and IterationPrefer iterator helpers over nested loopsreferences/loops-and-iteration.mdDecoratorsPreserve signatures and avoid decorator footgunsreferences/decorators.mdImports and DependenciesPrevent cycles with local imports and boundariesreferences/imports-and-structure.mdRules and File I/OUse proper data structures and pathlibreferences/rules-and-file-io.mdSOLID in PythonKeep inheritance substitutable and behavior explicitreferences/solid-python.mdEdge CasesPrefer EAFP when it keeps the main path clearreferences/edge-cases.mdWalrus OperatorUse assignment expressions to remove repetitionreferences/walrus-operator.md
urls.