nodes: 0, module; 1, function_definition; 2, function_name:strategy; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, function_definition; 10, return_statement; 11, identifier:names; 12, identifier:kwargs; 13, comment:"""
      StrategyDict wrapping method for adding a new strategy.
  
      Parameters
      ----------
      *names :
        Positional arguments with all names (strings) that could be used to
        call the strategy to be added, to be used both as key items and as
        attribute names.
      keep_name :
        Boolean keyword-only parameter for choosing whether the ``__name__``
        attribute of the decorated/wrapped function should be changed or kept.
        Defaults to False (i.e., changes the name by default).
  
      Returns
      -------
      A decorator/wrapper function to be used once on the new strategy to be
      added.
  
      Example
      -------
      Let's create a StrategyDict that knows its name:
  
      >>> txt_proc = StrategyDict("txt_proc")
  
      Add a first strategy ``swapcase``, using this method as a decorator
      factory:
  
      >>> @txt_proc.strategy("swapcase")
      ... def txt_proc(txt):
      ...   return txt.swapcase()
  
      Let's do it again, but wrapping the strategy functions inline. First two
      strategies have multiple names, the last keeps the function name, which
      would otherwise be replaced by the first given name:
  
      >>> txt_proc.strategy("lower", "low")(lambda txt: txt.lower())
      {(...): <function ... at 0x...>, (...): <function ... at 0x...>}
      >>> txt_proc.strategy("upper", "up")(lambda txt: txt.upper())
      {...}
      >>> txt_proc.strategy("keep", keep_name=True)(lambda txt: txt)
      {...}
  
      We can now iterate through the strategies to call them or see their
      function names
  
      >>> sorted(st("Just a Test") for st in txt_proc)
      ['JUST A TEST', 'Just a Test', 'jUST A tEST', 'just a test']
      >>> sorted(st.__name__ for st in txt_proc) # Just the first name
      ['<lambda>', 'lower', 'swapcase', 'upper']
  
      Calling a single strategy:
  
      >>> txt_proc.low("TeStInG")
      'testing'
      >>> txt_proc["upper"]("TeStInG")
      'TESTING'
      >>> txt_proc("TeStInG") # Default is the first: swapcase
      'tEsTiNg'
      >>> txt_proc.default("TeStInG")
      'tEsTiNg'
      >>> txt_proc.default = txt_proc.up # Manually changing the default
      >>> txt_proc("TeStInG")
      'TESTING'
  
      Hint
      ----
      Default strategy is the one stored as the ``default`` attribute, you can
      change or remove it at any time. When removing all keys that are assigned
      to the default strategy, the default attribute will be removed from the
      StrategyDict instance as well. The first strategy added afterwards is the
      one that will become the new default, unless the attribute is created or
      changed manually.
      """; 14, function_name:decorator; 15, parameters; 16, block; 17, identifier:decorator; 18, identifier:func; 19, expression_statement; 20, if_statement; 21, if_statement; 22, expression_statement; 23, return_statement; 24, assignment; 25, identifier:kwargs; 26, block; 27, not_operator; 28, block; 29, assignment; 30, identifier:self; 31, identifier:keep_name; 32, call; 33, expression_statement; 34, raise_statement; 35, identifier:keep_name; 36, expression_statement; 37, subscript; 38, identifier:func; 39, attribute; 40, argument_list; 41, assignment; 42, call; 43, assignment; 44, identifier:self; 45, identifier:names; 46, identifier:kwargs; 47, identifier:pop; 48, string:"keep_name"; 49, False; 50, identifier:key; 51, call; 52, identifier:TypeError; 53, argument_list; 54, attribute; 55, call; 56, identifier:next; 57, argument_list; 58, call; 59, identifier:func; 60, identifier:__name__; 61, identifier:str; 62, argument_list; 63, call; 64, attribute; 65, argument_list; 66, subscript; 67, identifier:iter; 68, argument_list; 69, string:"Unknown keyword argument '{}'"; 70, identifier:format; 71, identifier:key; 72, identifier:names; 73, integer:0; 74, identifier:kwargs
code: def strategy(self, *names, **kwargs):
      """
      StrategyDict wrapping method for adding a new strategy.
  
      Parameters
      ----------
      *names :
        Positional arguments with all names (strings) that could be used to
        call the strategy to be added, to be used both as key items and as
        attribute names.
      keep_name :
        Boolean keyword-only parameter for choosing whether the ``__name__``
        attribute of the decorated/wrapped function should be changed or kept.
        Defaults to False (i.e., changes the name by default).
  
      Returns
      -------
      A decorator/wrapper function to be used once on the new strategy to be
      added.
  
      Example
      -------
      Let's create a StrategyDict that knows its name:
  
      >>> txt_proc = StrategyDict("txt_proc")
  
      Add a first strategy ``swapcase``, using this method as a decorator
      factory:
  
      >>> @txt_proc.strategy("swapcase")
      ... def txt_proc(txt):
      ...   return txt.swapcase()
  
      Let's do it again, but wrapping the strategy functions inline. First two
      strategies have multiple names, the last keeps the function name, which
      would otherwise be replaced by the first given name:
  
      >>> txt_proc.strategy("lower", "low")(lambda txt: txt.lower())
      {(...): <function ... at 0x...>, (...): <function ... at 0x...>}
      >>> txt_proc.strategy("upper", "up")(lambda txt: txt.upper())
      {...}
      >>> txt_proc.strategy("keep", keep_name=True)(lambda txt: txt)
      {...}
  
      We can now iterate through the strategies to call them or see their
      function names
  
      >>> sorted(st("Just a Test") for st in txt_proc)
      ['JUST A TEST', 'Just a Test', 'jUST A tEST', 'just a test']
      >>> sorted(st.__name__ for st in txt_proc) # Just the first name
      ['<lambda>', 'lower', 'swapcase', 'upper']
  
      Calling a single strategy:
  
      >>> txt_proc.low("TeStInG")
      'testing'
      >>> txt_proc["upper"]("TeStInG")
      'TESTING'
      >>> txt_proc("TeStInG") # Default is the first: swapcase
      'tEsTiNg'
      >>> txt_proc.default("TeStInG")
      'tEsTiNg'
      >>> txt_proc.default = txt_proc.up # Manually changing the default
      >>> txt_proc("TeStInG")
      'TESTING'
  
      Hint
      ----
      Default strategy is the one stored as the ``default`` attribute, you can
      change or remove it at any time. When removing all keys that are assigned
      to the default strategy, the default attribute will be removed from the
      StrategyDict instance as well. The first strategy added afterwards is the
      one that will become the new default, unless the attribute is created or
      changed manually.
      """
      def decorator(func):
        keep_name = kwargs.pop("keep_name", False)
        if kwargs:
          key = next(iter(kwargs))
          raise TypeError("Unknown keyword argument '{}'".format(key))
        if not keep_name:
          func.__name__ = str(names[0])
        self[names] = func
        return self
      return decorator