Reputation: 21
I'm an experienced programmer, but completely new to Python. I've resolved most difficulties, but I can't get the queue module to work. Any help gratefully received. Python 3.2.
Reduced to its basic minimum, here's the issue:
>>>import queue
>>>q = queue.Queue
>>>q.qsize()
Traceback:
...
q.qsize()
...
TypeError: qsize() takes 1 argument exactly (0 given)
7.8.1. Queue Objects
Queue objects (Queue, LifoQueue, or PriorityQueue) provide the public methods described below.
Queue.qsize()
OK - what argument.... ?
Upvotes: 2
Views: 579
Reputation: 2098
You are simply renaming queue.Queue
and not instantiating an object.
Try this
q = queue.Queue()
print q.qsize()
Upvotes: 1
Reputation: 70632
You're not initializing an instance, you're just reassigning the class name to q
. The "argument" that it's talking about is self
, the explicit self-reference that all Python methods need. In other words, it's saying that you're trying to call an instance method with no instance.
>>> q = queue.Queue()
>>> q.qsize()
If you've never seen a Python method definition, it looks something like this:
class Queue(object):
# Note the explicit 'self' argument
def qsize(self):
# ...
Upvotes: 5