[IronPython] How do you detect operating systems from within IronPython?

Vernon Cole vernondcole at gmail.com
Mon Feb 21 19:05:42 CET 2011

I received a reminder today on a module I modified:
v v v
 dsblank <http://www.codeplex.com/site/users/view/dsblank> wrote Today at
8:01 AM
 Remember that IronPython runs on many different operating systems. It isn't
clear from the patch if this works on Mac and Linux under Mono.
^ ^ ^
Which brings up a really good point....

How do I tell what operating system IronPython is running on?

The original module (webbrowser.py) has lots of operating systems specific
code, all separated by:
if os.platform[:3] == 'win'
which I have modified to:
if os.platform[:3] in ['win','cli']

but that assumes that mono emulates Windows to a high degree, which thing I

The best guess I can make as to more correct code would be:

if os.platform[:3] == 'win' or (os.platform[:3] == 'cli' and os.linesep ==


How should I really be doing it?
Vernon Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20110221/b2271eb3/attachment.html>

More information about the Ironpython-users mailing list