Problem Regarding Queue

Stephen Hansen apt.shansen at gmail.com
Tue Feb 9 17:25:31 EST 2010


On Tue, Feb 9, 2010 at 2:06 PM, mukesh tiwari
<mukeshtiwari.iiitm at gmail.com>wrote:

> Could some one please tell what is wrong with this code. I am trying
> to use Queue in this program but i am getting error
> Traceback (most recent call last):
>  File "/home/user/NetBeansProjects/NewPythonProject2/src/
> Pollard_rho.py", line 80, in <module>
>    factor(n)
>  File "/home/user/NetBeansProjects/NewPythonProject2/src/
> Pollard_rho.py", line 59, in factor
>    Q_1=Queue()
> NameError: global name 'Queue' is not defined.
>

That's because you haven't imported the Queue module.

You need to do:

    import Queue

Then call:

    Q_1 = Queue.Queue()

Alternately, you can do:

    from Queue import Queue

And instantiate the class the same way you previously were.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100209/2dcdefee/attachment.html>


More information about the Python-list mailing list