def __init__(self, name=None, choices=[], default=None): Arg.__init__(self, name) if not util.is_string_or_unicode_list(choices): raise TypeError("'choices' must be a list of strings.") self.choices = choices if default is None: self.has_default = False self.default = 0 else: self.has_default = True self.default = default if not isinstance(self.default, CNoneDefault) and type(self.default) != int: raise TypeError("'default' must be an int")
def __init__(self, name=None, choices=[], default=None, strict=True): Arg.__init__(self, name) if not util.is_string_or_unicode_list(choices): raise TypeError("'choices' must be a list of strings.") self.choices = choices if default is None: self.has_default = False self.default = choices[0] else: if type(default) != str: raise TypeError("'default' must be a string") if default not in choices: raise ValueError("Given 'default' must be in available 'choices'") self.has_default = True self.default = default self.strict = strict