def popwhile(predicate, iterable):
while iterable:<EOL><INDENT>item = iterable.pop()<EOL>if predicate(item):<EOL><INDENT>yield item<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>
Generator function yielding items of iterable while predicate holds for each item

    :param predicate: function taking an item returning bool
    :param iterable: iterable
    :returns: iterable (generator function)