parameters: (input_list)
return_statement: return out_lists
docstring: Return a list containing all permutations of the input list.
  
      Note: This is a recursive function.
  
      >>> perms = permutations(['a', 'b', 'c'])
      >>> perms.sort()
      >>> for perm in perms:
      ...     print perm
      ['a', 'b', 'c']
      ['a', 'c', 'b']
      ['b', 'a', 'c']
      ['b', 'c', 'a']
      ['c', 'a', 'b']
      ['c', 'b', 'a']
docstring_summary: Return a list containing all permutations of the input list.
docstring_tokens: Return a list containing all permutations of the input list .
function: def permutations(input_list):
      """Return a list containing all permutations of the input list.
  
      Note: This is a recursive function.
  
      >>> perms = permutations(['a', 'b', 'c'])
      >>> perms.sort()
      >>> for perm in perms:
      ...     print perm
      ['a', 'b', 'c']
      ['a', 'c', 'b']
      ['b', 'a', 'c']
      ['b', 'c', 'a']
      ['c', 'a', 'b']
      ['c', 'b', 'a']
  
      """
      out_lists = []
      if len(input_list) > 1:
          # Extract first item in list.
          item = input_list[0]
          # Find all permutations of remainder of list. (Recursive call.)
          sub_lists = permutations(input_list[1:])
          # For every permutation of the sub list...
          for sub_list in sub_lists:
              # Insert the extracted first item at every position of the list.
              for i in range(len(input_list)):
                  new_list = sub_list[:]
                  new_list.insert(i, item)
                  out_lists.append(new_list)
      else:
          # Termination condition: only one item in input list.
          out_lists = [input_list]
      return out_lists
function_tokens: def permutations ( input_list ) : out_lists = [ ] if len ( input_list ) > 1 : # Extract first item in list. item = input_list [ 0 ] # Find all permutations of remainder of list. (Recursive call.) sub_lists = permutations ( input_list [ 1 : ] ) # For every permutation of the sub list... for sub_list in sub_lists : # Insert the extracted first item at every position of the list. for i in range ( len ( input_list ) ) : new_list = sub_list [ : ] new_list . insert ( i , item ) out_lists . append ( new_list ) else : # Termination condition: only one item in input list. out_lists = [ input_list ] return out_lists