TypeError: Python thinks that I passed a function 2 arguments but I only passed it 1
- by slhck
I work on something in Seattle Repy which is a restricted subset of Python. Anyway, I wanted to implement my own Queue that derives from a list:
class Queue(list):
job_count = 0
def __init__(self):
list.__init__(self)
def appendleft(item):
item.creation_time = getruntime()
item.current_count = self.job_count
self.insert(0, item)
def pop():
item = self.pop()
item.pop_time = getruntime()
return item
Now I call this in my main server, where I use my own Job class to pass Jobs to the Queue:
mycontext['queue'] = Queue()
# ...
job = Job(str(ip), message)
mycontext['queue'].appendleft(job)
The last line raises the following exception:
Exception (with type 'exceptions.TypeError'): appendleft() takes exactly 1 argument (2 given)
I'm relatively new to Python, so could anyone explain to me why it would think that I gave appendleft() two arguments when there obviously was only one?