Recently, I want to add the user OS version information in my Youmoney (http://code.google.com/p/youmoney/). For example, Windows users may want to return Windows XP, or Windows 2003, Apple users should return to Mac OS X 10.5.8. There are many ways to do this, including invoking system commands, taking environment variables, and so on in Mac systems. In the end, there is a platform module in Python that can do this thing. Oh, easy!
Doing this on your Mac.
The code is as follows:
localhost:~ apple$ python
Python 2.5.1 (r251:54863, June 17 2009, 20:37:34)
[GCC 4.0.1 (Apple Inc. build 5465)] on Darwin
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import Platform
>>> Platform.mac_ver ()
(' 10.5.8 ', (', ', ', '), ' i386 ')
>>> platform.version ()
' Darwin Kernel Version 9.8.0:wed Jul 16:55:01 PDT 2009; Root:xnu-1228.15.4~1/release_i386 '
>>> Platform.platform ()
' Darwin-9.8.0-i386-32bit '
>>> Platform.system ()
' Darwin '
>>>
Basically using Platform.platform () is enough. If it is on Windows, there is a special platform.win32_ver () available.