def _mac_ver_gestalt():
 try:
  import gestalt
  import MacOS
 except ImportError:
  return None
 (sysv, sysa) = _mac_ver_lookup(('sysv', 'sysa'))
 if sysv:
  major = ((sysv & 65280) >> 8)
  minor = ((sysv & 240) >> 4)
  patch = (sysv & 15)
  if ((major, minor) >= (10, 4)):
   (major, minor, patch) = _mac_ver_lookup(('sys1', 'sys2', 'sys3'))
   release = ('%i.%i.%i' % (major, minor, patch))
  else:
   release = ('%s.%i.%i' % (_bcd2str(major), minor, patch))
 if sysa:
  machine = {1: '68k', 2: 'PowerPC', 10: 'i386'}.get(sysa, '')
 versioninfo = ('', '', '')
 return (release, versioninfo, machine)

def _mac_ver_gestalt ( ) : try : import gestalt import MacOS except ImportError : return None ( sysv , sysa ) = _mac_ver_lookup ( ( 'sysv' , 'sysa' ) ) if sysv : major = ( ( sysv & 65280 ) >> 8 ) minor = ( ( sysv & 240 ) >> 4 ) patch = ( sysv & 15 ) if ( ( major , minor ) >= ( 10 , 4 ) ) : ( major , minor , patch ) = _mac_ver_lookup ( ( 'sys1' , 'sys2' , 'sys3' ) ) release = ( '%i.%i.%i' % ( major , minor , patch ) ) else : release = ( '%s.%i.%i' % ( _bcd2str ( major ) , minor , patch ) ) if sysa : machine = { 1 : '68k' , 2 : 'PowerPC' , 10 : 'i386' } . get ( sysa , '' ) versioninfo = ( '' , '' , '' ) return ( release , versioninfo , machine )
thanks to mark r .