<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def constraint_from_choices(cls, value_type: type, choices: collections.Sequence):
 """ Returns a constraint callable based on choices of a given type """

        choices_str = ', '.join(map(str, choices))

        def constraint(value):
            value = value_type(value)
            if value not in choices:
                raise ParameterError('Argument must be one of %s' % choices_str)
            return value

        constraint.__name__ = 'choices_%s' % value_type.__name__
        constraint.__doc__ = 'choice of %s' % choices_str
        return constraint