diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-11-16 19:25:34 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-11-16 19:27:07 -0500 |
commit | 4861a0d958f0ccc9d1dcca14dd9f8550dc47309c (patch) | |
tree | b80e210fc5eed73fed2258768f5bbe494e89734a | |
parent | 779793c74698e40fe11ceeb0debc826beed9d786 (diff) | |
download | kutter-4861a0d958f0ccc9d1dcca14dd9f8550dc47309c.tar.gz kutter-4861a0d958f0ccc9d1dcca14dd9f8550dc47309c.tar.xz kutter-4861a0d958f0ccc9d1dcca14dd9f8550dc47309c.zip |
docs: Add recommendation on Python type handling to Code_Overview.md
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | docs/Code_Overview.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/Code_Overview.md b/docs/Code_Overview.md index 170185b7..bd8c3075 100644 --- a/docs/Code_Overview.md +++ b/docs/Code_Overview.md @@ -311,6 +311,16 @@ The following may also be useful: * Avoid accessing the internal member variables (or calling methods that start with an underscore) of other printer objects. Observing this convention makes it easier to manage future changes. +* It is recommended to assign a value to all member variables in the + Python constructor of Python classes. (And therefore avoid utilizing + Python's ability to dynamically create new member variables.) +* If a Python variable is to store a floating point value then it is + recommended to always assign and manipulate that variable with + floating point constants (and never use integer constants). For + example, prefer `self.speed = 1.` over `self.speed = 1`, and prefer + `self.speed *= 2.` over `self.speed *= 2`. Consistent use of + floating point values can avoid hard to debug quirks in Python type + conversions. * If submitting the module for inclusion in the main Klipper code, be sure to place a copyright notice at the top of the module. See the existing modules for the preferred format. |