The currently accepted answer uses an obsolete function. The correct way to do this with Python 2.6 and later:
import platform print(platform.linux_distribution())
The documentation does not indicate whether this feature is available on platforms other than Linux, but on my local Windows desktop I get:
>>> import platform >>> print(platform.linux_distribution()) ('', '', '')
There's also this to do something similar on Win32 machines:
>>> print(platform.win32_ver()) ('post2008Server', '6.1.7601', 'SP1', 'Multiprocessor Free')
unwind
source share