I’m writing some POSIX-specific code, and although I’m not supporting other platforms I’d like to make sure they get a nice clear error at import time rather than strange errors, if they tried to use my code.
Is there a neat way to check that? I guess I could to an import posix and catch the ImportError but that seems kind of verbose.
Take a look at
os.name:There are also
sys.platformandos.uname()if you require finer granularity.