[IronPython] What is a good way to determine OS platform with IronPython?

Dino Viehland dinov at microsoft.com
Tue Jan 11 00:27:58 CET 2011


Doug wrote:
> > On Mon, Jan 10, 2011 at 3:37 PM, Douglas Blank <dblank at brynmawr.edu>
> > wrote:
> >> Now that IronPython runs on other operating systems, what is the
> >> recommended way to determine the os when running IP?
> >
> > `os.name` is probably what you want. There was some discussion on
> > python-dev about a module (or extension to sys?) that would have a lot
> > more information, but I can't remember what it was going to be called.
> 
> Thanks. FYI, under Mono:
> 
> IP on mac: os.name == 'posix'
> IP on linux: os.name == 'posix'
> IP on windows 7: os.name == 'nt'
> 
> I'll have to figure out a different way to distinguish between mac and linux.
> Even sys.getwindowsversion() gives a platform of 4 for Mac and Linux under
> Mono.

Another option is to import System and then System.Environment.OSVersion 
should have detailed information.  The Platform attribute would give you a
difference between Unix and Mac OS/X and depending on what Mono does
w/ the value you might get a useful ToString on the OperatingSystem object
its self.



More information about the Ironpython-users mailing list