How to determine if a GH python node runs within a Windows or Mac environment

I have developed a python component that takes as input a list of textual or numeric data. I had it developed in such a way that, when the data is provided in a panel, it didn’t matter whether the data was multi-line data or a proper list. It would check if ‘\r\n’ occurs in the string and, if so, split the string over ‘\r\n’. I realize this works fine on Windows but not on Mac, on the latter, I should simply be looking for ‘\n’.
I could write the code in such a way that I first search for ‘\r\n’ and, if that is not successful, for ‘\n’. However, it might just be better to check for the environment on which Rhino is running. But I’m not sure how to do that. I know it is possible to determine the Rhino and RhinoScript version, but this information is not reflective of the OS environment. How can I query which OS environment Rhino is running in from Python?

This should do it (haven’t tested on Mac though):

import platform
print platform.platform()


Stackoverflow is your friend for general python questions like this:

import platform

The output of platform.system() is as follows:

  • Linux: Linux
  • Mac: Darwin
  • Windows: Windows

Source :


1 Like

Thanks, I didn’t quite realize it is a general python question, but it makes perfectly sense.

1 Like