def removedirs(name):
 rmdir(name)
 (head, tail) = path.split(name)
 if (not tail):
  (head, tail) = path.split(head)
 while (head and tail):
  try:
   rmdir(head)
  except error:
   break
  (head, tail) = path.split(head)

def removedirs ( name ) : rmdir ( name ) ( head , tail ) = path . split ( name ) if ( not tail ) : ( head , tail ) = path . split ( head ) while ( head and tail ) : try : rmdir ( head ) except error : break ( head , tail ) = path . split ( head )
removedirs super-rmdir; remove a leaf directory and all empty intermediate ones .