<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def foreach(self, argv, func):
 """Apply the function to each job specified in the argument vector."""

        if len(argv) == 0:
            error("Command requires a search specifier.", 2)
        for item in argv:
            job = self.lookup(item)
            if job is None:
                error("Search job '%s' does not exist" % item, 2)
            func(job)