def constraint_for(type_or_constraint):
 if isinstance(type_or_constraint, Exactly):
  return type_or_constraint
 elif isinstance(type_or_constraint, type):
  return Exactly(type_or_constraint)
 else:
  raise TypeError(u'Expected a type or constraint: got: {}'.format(type_or_constraint))

def constraint_for ( type_or_constraint ) : if isinstance ( type_or_constraint , Exactly ) : return type_or_constraint elif isinstance ( type_or_constraint , type ) : return Exactly ( type_or_constraint ) else : raise TypeError ( u'Expected a type or constraint: got: {}' . format ( type_or_constraint ) )
given a type or an exactly constraint .