def architecture(executable=sys.executable, bits='', linkage=''):
 if (not bits):
  import struct
  try:
   size = struct.calcsize('P')
  except struct.error:
   size = struct.calcsize('l')
  bits = (str((size * 8)) + 'bit')
 if executable:
  output = _syscmd_file(executable, '')
 else:
  output = ''
 if ((not output) and (executable == sys.executable)):
  if (sys.platform in _default_architecture):
   (b, l) = _default_architecture[sys.platform]
   if b:
    bits = b
   if l:
    linkage = l
  return (bits, linkage)
 fileout = _architecture_split(output)[1:]
 if ('executable' not in fileout):
  return (bits, linkage)
 if ('32-bit' in fileout):
  bits = '32bit'
 elif ('N32' in fileout):
  bits = 'n32bit'
 elif ('64-bit' in fileout):
  bits = '64bit'
 if ('ELF' in fileout):
  linkage = 'ELF'
 elif ('PE' in fileout):
  if ('Windows' in fileout):
   linkage = 'WindowsPE'
  else:
   linkage = 'PE'
 elif ('COFF' in fileout):
  linkage = 'COFF'
 elif ('MS-DOS' in fileout):
  linkage = 'MSDOS'
 else:
  pass
 return (bits, linkage)

def architecture ( executable = sys . executable , bits = '' , linkage = '' ) : if ( not bits ) : import struct try : size = struct . calcsize ( 'P' ) except struct . error : size = struct . calcsize ( 'l' ) bits = ( str ( ( size * 8 ) ) + 'bit' ) if executable : output = _syscmd_file ( executable , '' ) else : output = '' if ( ( not output ) and ( executable == sys . executable ) ) : if ( sys . platform in _default_architecture ) : ( b , l ) = _default_architecture [ sys . platform ] if b : bits = b if l : linkage = l return ( bits , linkage ) fileout = _architecture_split ( output ) [ 1 : ] if ( 'executable' not in fileout ) : return ( bits , linkage ) if ( '32-bit' in fileout ) : bits = '32bit' elif ( 'N32' in fileout ) : bits = 'n32bit' elif ( '64-bit' in fileout ) : bits = '64bit' if ( 'ELF' in fileout ) : linkage = 'ELF' elif ( 'PE' in fileout ) : if ( 'Windows' in fileout ) : linkage = 'WindowsPE' else : linkage = 'PE' elif ( 'COFF' in fileout ) : linkage = 'COFF' elif ( 'MS-DOS' in fileout ) : linkage = 'MSDOS' else : pass return ( bits , linkage )
returns the bit depth of the python interpreters architecture as a string .