def from_tuple(tup):
 if (len(tup) not in (2, 3)):
  raise ValueError(('tuple must contain 2 or 3 elements, not: %d (%r' % (len(tup), tup)))
 return range(*tup)

def from_tuple ( tup ) : if ( len ( tup ) not in ( 2 , 3 ) ) : raise ValueError ( ( 'tuple must contain 2 or 3 elements, not: %d (%r' % ( len ( tup ) , tup ) ) ) return range ( * tup )
convert a tuple into a range with error handling .