def required_length(nmin, nmax):
 class RequiredLength(Action, ):
  def __call__(self, parser, args, values, option_string=None):
   if (not (nmin <= len(values) <= nmax)):
    raise ArgumentError(self, (u'requires between %s and %s arguments' % (nmin, nmax)))
   setattr(args, self.dest, values)
 return RequiredLength

def required_length ( nmin , nmax ) : class RequiredLength ( Action , ) : def __call__ ( self , parser , args , values , option_string = None ) : if ( not ( nmin <= len ( values ) <= nmax ) ) : raise ArgumentError ( self , ( u'requires between %s and %s arguments' % ( nmin , nmax ) ) ) setattr ( args , self . dest , values ) return RequiredLength
generates a custom action to validate an arbitrary range of arguments .