The Pushes Were Fine
import heapq
class Job:
def __init__(self, name):
self.name = name
q = []
heapq.heappush(q, (5, Job("backup"))) # line A
heapq.heappush(q, (3, Job("index"))) # line B
heapq.heappush(q, (5, Job("email"))) # line C
print(heapq.heappop(q)) # line D
Job defines no comparison methods. Which line raises TypeError, and why?
Sign in to answer questions and track your progress
Sign In