def abbrev_list(vals):
 ranges = []
 lower = 0
 upper = (-2)
 for val in (sorted(vals) + [(-1)]):
  if (val != (upper + 1)):
   if (lower == upper):
    ranges.append(str(lower))
   elif (lower <= upper):
    ranges.append(('%d-%d' % (lower, upper)))
   lower = val
  upper = val
 return ','.join(ranges)

def abbrev_list ( vals ) : ranges = [ ] lower = 0 upper = ( - 2 ) for val in ( sorted ( vals ) + [ ( - 1 ) ] ) : if ( val != ( upper + 1 ) ) : if ( lower == upper ) : ranges . append ( str ( lower ) ) elif ( lower <= upper ) : ranges . append ( ( '%d-%d' % ( lower , upper ) ) ) lower = val upper = val return ',' . join ( ranges )
condense unsigned to 0 .