I'm installing some open source software in Python that makes use of the errno
module and want to make it installable across multiple environments whose errno
modules might differ. What is a good pattern for this?
Here's my specific case. The code uses errno.ETIME
. However, ETIME
is not in every version of errno
. For example, in Anaconda for Python 2 on Windows. (Or maybe this is specific to my Windows installation?)
Now, one way around it is to check for it and assign it if it's not there:
import errno
if 'ETIME' not in dir(errno):
errno.ETIME = 127
But that feels hacky. Is there a best practice for this? Thanks.