Files
pybricks-api/examples/micropython/oserror.py
T
Laurens Valk e8d47ffca1 uerrno: Document alongside OSError.
These are meant to be used together, so document them in the same place along with a practical example.
2021-07-19 15:03:10 +02:00

12 lines
263 B
Python

from pybricks.pupdevices import Motor
from pybricks.parameters import Port
from uerrno import ENODEV
try:
my_motor = Motor(Port.A)
print("Detected a motor.")
except OSError as ex:
if ex.errno == ENODEV:
print("There is no motor this port.")