8000 update design guide · alexbartlow/circuitpython@ac6695f · GitHub
[go: up one dir, main page]

Skip to content

Commit ac6695f

Browse files
committed
update design guide
1 parent aae10fb commit ac6695f
< 8000 /div>

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/design_guide.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ use what.
165165
Here is more info on properties from
166166
`Python <https://docs.python.org/3/library/functions.html#property>`_.
167167

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+
168186
Design for compatibility with CPython
169187
--------------------------------------------------------------------------------
170188

0 commit comments

Comments
 (0)
0