parameters: (old, new)
docstring: renames(old, new)
  
      Super-rename; create directories as necessary and delete any left
      empty.  Works like rename, except creation of any intermediate
      directories needed to make the new pathname good is attempted
      first.  After the rename, directories corresponding to rightmost
      path segments of the old name will be pruned way until either the
      whole path is consumed or a nonempty directory is found.
  
      Note: this function can fail with the new directory structure made
      if you lack permissions needed to unlink the leaf directory or
      file.
docstring_summary: renames(old, new)
docstring_tokens: renames ( old new )
function: def renames(old, new):
      """renames(old, new)
  
      Super-rename; create directories as necessary and delete any left
      empty.  Works like rename, except creation of any intermediate
      directories needed to make the new pathname good is attempted
      first.  After the rename, directories corresponding to rightmost
      path segments of the old name will be pruned way until either the
      whole path is consumed or a nonempty directory is found.
  
      Note: this function can fail with the new directory structure made
      if you lack permissions needed to unlink the leaf directory or
      file.
  
      """
      head, tail = path.split(new)
      if head and tail and not path.exists(head):
          makedirs(head)
      rename(old, new)
      head, tail = path.split(old)
      if head and tail:
          try:
              removedirs(head)
          except error:
              pass
function_tokens: def renames ( old , new ) : head , tail = path . split ( new ) if head and tail and not path . exists ( head ) : makedirs ( head ) rename ( old , new ) head , tail = path . split ( old ) if head and tail : try : removedirs ( head ) except error : pass