TypeError: Python thinks that I passed a function 2 arguments but I only passed it 1

Posted by slhck on Stack Overflow See other posts from Stack Overflow or by slhck
Published on 2010-12-21T12:49:02Z Indexed on 2010/12/21 12:54 UTC
Read the original article Hit count: 268

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about python

Related posts about exception