everyone's an amateur

August 18, 2011 @ 14:04

Yep, I’m doing it again. I’m trying to fix poorly-written libraries. This time it’s the python bindings for net-snmp, the most popular SNMP library for unix.

Libraries should never, just print error messages when they can instead throw an exception. Throwing an exception means the application developer using your library has an opportunity to handle the error gracefully, rather than having the library just crash, or in this case, not being able to determine an error condition even exists.

Bad practice. Here’s a link to my bug report.
Until they fix it, just edit netsnmp/client.py and replace the print stderr... line with one that throws a useful exception.