def guess_idnumber(string):
 ret = []
 matches = list(_idnum.finditer(string))
 for match in matches:
  result = match.groupdict()
  switch_count = 0
  switch_letter_count = 0
  letter_count = 0
  last_letter = None
  last = _LETTER
  for c in result['uuid']:
   if (c in '0123456789'):
    ci = _DIGIT
   elif (c in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'):
    ci = _LETTER
    if (c != last_letter):
     switch_letter_count += 1
    last_letter = c
    letter_count += 1
   else:
    ci = _OTHER
   if (ci != last):
    switch_count += 1
   last = ci
  switch_ratio = (float(switch_count) / len(result['uuid']))
  letters_ratio = ((float(switch_letter_count) / letter_count) if (letter_count > 0) else 1)
  if ((switch_ratio > 0.4) and (letters_ratio > 0.4)):
   ret.append(match.span())
 return ret

def guess_idnumber ( string ) : ret = [ ] matches = list ( _idnum . finditer ( string ) ) for match in matches : result = match . groupdict ( ) switch_count = 0 switch_letter_count = 0 letter_count = 0 last_letter = None last = _LETTER for c in result [ 'uuid' ] : if ( c in '0123456789' ) : ci = _DIGIT elif ( c in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) : ci = _LETTER if ( c != last_letter ) : switch_letter_count += 1 last_letter = c letter_count += 1 else : ci = _OTHER if ( ci != last ) : switch_count += 1 last = ci switch_ratio = ( float ( switch_count ) / len ( result [ 'uuid' ] ) ) letters_ratio = ( ( float ( switch_letter_count ) / letter_count ) if ( letter_count > 0 ) else 1 ) if ( ( switch_ratio > 0.4 ) and ( letters_ratio > 0.4 ) ) : ret . append ( match . span ( ) ) return ret
guess id number function .