Helper function for creating new choice types.
  This can be called either as:
     Choice(Name, [Type1, Type2, ...])
  or:
     Choice([Type1, Type2, ...])
  In the latter case, the name of the new type will be autogenerated, and will
  look like "Choice_Type1_Type2".

def Choice(*args):
  """Helper function for creating new choice types.
  This can be called either as:
     Choice(Name, [Type1, Type2, ...])
  or:
     Choice([Type1, Type2, ...])
  In the latter case, the name of the new type will be autogenerated, and will
  look like "Choice_Type1_Type2".
  """
  if len(args) == 2:
    name, alternatives = args
  else:
    name = "Choice_" + "_".join(a.__name__ for a in args[0])
    alternatives = args[0]
  assert isinstance(name, Compatibility.stringy)
  assert all(issubclass(t, Type) for t in alternatives)
  return TypeFactory.new({}, ChoiceFactory.PROVIDES, name,
                         tuple(t.serialize_type() for t in alternatives))