def reverse_tag_iter(block):
 end = len(block)
 while True:
  pgt = block.rfind('>', 0, end)
  if (pgt == (-1)):
   break
  plt = block.rfind('<', 0, pgt)
  if (plt == (-1)):
   break
  (yield block[plt:(pgt + 1)])
  end = plt

def reverse_tag_iter ( block ) : end = len ( block ) while True : pgt = block . rfind ( '>' , 0 , end ) if ( pgt == ( - 1 ) ) : break plt = block . rfind ( '<' , 0 , pgt ) if ( plt == ( - 1 ) ) : break ( yield block [ plt : ( pgt + 1 ) ] ) end = plt
iterate over all tags in block in reverse order .