  def filter_lastline(file, predicate):     """Find the last line in *file* that satisfies *predicate*."""     lines = collections.deque(filter(predicate, file), maxlen=0)     try:         return lines.pop().rstrip('\n')     except IndexError:         return ''  # not found  def update_label(root, label, last_line):     current = label['text']     new = last_line()     if new and current != new:         label['text'] = new  # update label  def main():     root = tkinter.Tk()     root.withdraw()  # hide the main window     try:  # handle command-line arguments         regex_string, path = sys.argv[0:]         found = re.compile(regex_string).search         file = open(path)     except Exception as e:         tkinter.messagebox.showerror('wrong command-line arguments',                                      'error: %s\n%s' % (e, __doc__),                                      parent=root)         sys.exit(__doc__)      last_line = functools.partial(filter_lastline, file, found)     label = tkinter.Label(root, text=last_line()                           or '<nothing matched %r>' % regex_string)     label.pack()      