From 62cc09e50cee5772ce77daaa034a30b063d8a76e Mon Sep 17 00:00:00 2001 From: Matthew Shafer Date: Wed, 17 Nov 2021 15:25:35 -0600 Subject: [PATCH] treat global mutables as global vars --- docs/Coding-Conventions.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/Coding-Conventions.md b/docs/Coding-Conventions.md index 4eeb8b98..eccbab26 100644 --- a/docs/Coding-Conventions.md +++ b/docs/Coding-Conventions.md @@ -340,6 +340,20 @@ FlyingCircus_contra = TypeVar("FlyingCircus_contra", contravariant=True) ℹ️ This invokes Python's name mangling which does have well-known, yet unintended side-effects. See [the docs](https://docs.python.org/3.6/tutorial/classes.html#private-variables) +### [N.2.12] ✔️ **DO** Name global *mutable* objects as global variables (i.e., use `snake_case`) + +ℹ️ While it can be argued that a global reference that should not be re-assigned is a CONST, we chose to acknowledge that global *mutable* objects are variables whose behavior may change without getting re-assigned. + +```python +# Bad +CHEESE_LOGGER = logging.getLogger("Cheese") +``` + +```python +# Good +_logger = logging.getLogger("Cheese") +``` + --- # [L] Language Features