I must admit that I wasn’t actually aware of platform module, which has been around since Python 2.3. Now the latest stable version in 3.3, well 3.3 - 2.3 = 1.0, not too late, am I?

A system monitor program called Glances shows me:

Gentoo Base System 2.1 64bit with Linux 3.5.7-gentoo-3 on dfed

At first, I thought it must parse the release file /etc/distro-name-release on its own, but it actually uses platform module.

import platform as p

for attr in (attr for attr in dir(p) if not attr.startswith('_')):
  try:
    print('{:21s} = {!r}'.format(attr, getattr(p, attr)()))
  except:
    pass
architecture          = ('64bit', 'ELF')
dist                  = ('gentoo', '2.1', '')
java_ver              = ('', '', ('', '', ''), ('', '', ''))
libc_ver              = ('glibc', '2.2.5')
linux_distribution    = ('Gentoo Base System', '2.1', '')
mac_ver               = ('', ('', '', ''), '')
machine               = 'x86_64'
node                  = 'dfed'
platform              = 'Linux-3.5.7-gentoo-3-x86_64-Intel-R-_Core-TM-2_CPU_T5600_@_1.83GHz-with-gentoo-2.1'
processor             = 'Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz'
python_branch         = ''
python_build          = ('default', 'Jun 12 2012 00:04:22')
python_compiler       = 'GCC 4.5.3'
python_implementation = 'CPython'
python_revision       = ''
python_version        = '2.7.3'
python_version_tuple  = ('2', '7', '3')
release               = '3.5.7-gentoo-3'
system                = 'Linux'
uname                 = ('Linux', 'dfed', '3.5.7-gentoo-3', '#3 SMP PREEMPT Tue Nov 20 00:20:28 CST 2012', 'x86_64', 'Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz')
version               = '#3 SMP PREEMPT Tue Nov 20 00:20:28 CST 2012'
win32_ver             = ('', '', '', '')

Before this, I would look into os.name, os.uname(), or sys.platform for operating system’s information. sys.version_info for Python version information.