File tree 1 file changed +18
-0
lines changed 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,24 @@ use what.
165
165
Here is more info on properties from
166
166
`Python <https://docs.python.org/3/library/functions.html#property >`_.
167
167
168
+ Exceptions and asserts
169
+ --------------------------------------------------------------------------------
170
+
171
+ Raise an appropriate `Exception <https://docs.python.org/3/library/exceptions.html#bltin-exceptions >`_,
172
+ along with a useful message, whenever a critical test or other condition fails.
173
+
174
+ Example::
175
+
176
+ if not 0 <= pin <= 7:
177
+ raise ValueError("Pin number must be 0-7.")
178
+
179
+ If memory is constrained and a more compact method is needed, use `assert `
180
+ instead.
181
+
182
+ Example::
183
+
184
+ assert 0 <= pin <= 7, "Pin number must be 0-7."
185
+
168
186
Design for compatibility with CPython
169
187
--------------------------------------------------------------------------------
170
188
You can’t perform that action at this time.
0 commit comments