code: def yank_nth_arg(self, n=None, _yank_last_arg=False):
          
          assert n is None or isinstance(n, int)
  
          if not len(self.history):
              return
  
          # Make sure we have a `YankNthArgState`.
          if self.yank_nth_arg_state is None:
              state = YankNthArgState(n=-1 if _yank_last_arg else 1)
          else:
              state = self.yank_nth_arg_state
  
          if n is not None:
              state.n = n
  
          # Get new history position.
          new_pos = state.history_position - 1
          if -new_pos > len(self.history):
              new_pos = -1
  
          # Take argument from line.
          line = self.history[new_pos]
  
          words = [w.strip() for w in _QUOTED_WORDS_RE.split(line)]
          words = [w for w in words if w]
          try:
              word = words[state.n]
          except IndexError:
              word = ''
  
          # Insert new argument.
          if state.previous_inserted_word:
              self.delete_before_cursor(len(state.previous_inserted_word))
          self.insert_text(word)
  
          # Save state again for next completion. (Note that the 'insert'
          # operation from above clears `self.yank_nth_arg_state`.)
          state.previous_inserted_word = word
          state.history_position = new_pos
          self.yank_nth_arg_state = state
docs: Pick nth word from previous history entry (depending on current
          `yank_nth_arg_state`) and insert it at current position. Rotate through
          history if called repeatedly. If no `n` has been given, take the first
          argument. (The second word.)
  
          :param n: (None or int), The index of the word from the previous line
              to take.