def positional(max_positional_args):
 def positional_decorator(wrapped):
  @functools.wraps(wrapped)
  def positional_wrapper(*args, **kwargs):
   if (len(args) > max_positional_args):
    plural_s = ''
    if (max_positional_args != 1):
     plural_s = 's'
    message = ('%s() takes at most %d positional argument%s (%d given)' % (wrapped.__name__, max_positional_args, plural_s, len(args)))
    if (positional_parameters_enforcement == POSITIONAL_EXCEPTION):
     raise TypeError(message)
    elif (positional_parameters_enforcement == POSITIONAL_WARNING):
     logger.warning(message)
    else:
     pass
   return wrapped(*args, **kwargs)
  return positional_wrapper
 if isinstance(max_positional_args, six.integer_types):
  return positional_decorator
 else:
  (args, _, _, defaults) = inspect.getargspec(max_positional_args)
  return positional((len(args) - len(defaults)))(max_positional_args)

def positional ( max_positional_args ) : def positional_decorator ( wrapped ) : @ functools . wraps ( wrapped ) def positional_wrapper ( * args , ** kwargs ) : if ( len ( args ) > max_positional_args ) : plural_s = '' if ( max_positional_args != 1 ) : plural_s = 's' message = ( '%s() takes at most %d positional argument%s (%d given)' % ( wrapped . __name__ , max_positional_args , plural_s , len ( args ) ) ) if ( positional_parameters_enforcement == POSITIONAL_EXCEPTION ) : raise TypeError ( message ) elif ( positional_parameters_enforcement == POSITIONAL_WARNING ) : logger . warning ( message ) else : pass return wrapped ( * args , ** kwargs ) return positional_wrapper if isinstance ( max_positional_args , six . integer_types ) : return positional_decorator else : ( args , _ , _ , defaults ) = inspect . getargspec ( max_positional_args ) return positional ( ( len ( args ) - len ( defaults ) ) ) ( max_positional_args )
a decorator to declare that only the first n arguments may be positional .