Search code examples
pythonwindowsplatform-detection

Reliably detect Windows in Python


I'm working on a couple of Linux tools and need to prevent installation on Windows, since it depends on FHS and is thus rendered useless on that platform. The platform.platform function comes close but only returns a string.

Unfortunately I don't know what to search for in that string for it to yield a reliable result. Does anyone know what to search for or does anyone know of another function that I'm missing here?


Solution

  • >>> import platform
    >>> platform.system()
    'Windows'