Python Forum
looking for a custom exception
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looking for a custom exception
#5
(Sep-21-2020, 05:48 PM)JarredAwesome Wrote: Here is what is in the modules __init__.py file
I know what's in __init__.py - that's why I show it to you. In my code I import the module w1thermsensor and then fully reference the W1ThermSensor and NoSensorFoundError
If you prefer from w1thermsensor import W1ThermSensor, then it should be

from w1thermsensor import W1ThermSensor, NoSensorFoundError

try:
    sensor = W1ThermSensor(W1ThermSensor.THERM_SENSOR_DS18B20, '0300a27989945')
except NoSensorFoundError:
    print('Thermometer not Found')
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
looking for a custom exception - by JarredAwesome - Sep-21-2020, 02:26 AM
RE: looking for a custom exception - by bowlofred - Sep-21-2020, 04:00 AM
RE: looking for a custom exception - by buran - Sep-21-2020, 05:25 AM
RE: looking for a custom exception - by buran - Sep-21-2020, 05:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  custom exception dcr 1 319 Feb-17-2024, 08:19 PM
Last Post: Gribouillis
  problem using custom exception handling in python srm 3 3,096 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  During handling of the above exception, another exception occurred Skaperen 7 26,989 Dec-21-2018, 10:58 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020