def as_tuple(x, N, t=None):
 try:
  X = tuple(x)
 except TypeError:
  X = ((x,) * N)
 if ((t is not None) and (not all((isinstance(v, t) for v in X)))):
  raise TypeError('expected a single value or an iterable of {0}, got {1} instead'.format(t.__name__, x))
 if (len(X) != N):
  raise ValueError('expected a single value or an iterable with length {0}, got {1} instead'.format(N, x))
 return X

def as_tuple ( x , N , t = None ) : try : X = tuple ( x ) except TypeError : X = ( ( x , ) * N ) if ( ( t is not None ) and ( not all ( ( isinstance ( v , t ) for v in X ) ) ) ) : raise TypeError ( 'expected a single value or an iterable of {0}, got {1} instead' . format ( t . __name__ , x ) ) if ( len ( X ) != N ) : raise ValueError ( 'expected a single value or an iterable with length {0}, got {1} instead' . format ( N , x ) ) return X
coerce a value to a tuple of given length .