queue.Queue problem

This is the place for queries that don't fit in any of the other categories.

queue.Queue problem

Postby abhi1988srivastava » Sun Nov 17, 2013 9:11 pm

Hi,

I have to use queue to implement some algorithm. I thought of using deque but since I have to add int , which is not iterable and cant convert to string since it will effect further operations so thought of using queue.Queue but my program is not exiting and neither giving error. Here by pasting excerpt from the code..please help :

Code: Select all
Q=Queue()
Q.put(s)
while Q:
    u = Q.get()


where s is an int.

Thanks
Abhinav.
abhi1988srivastava
 
Posts: 11
Joined: Mon Sep 09, 2013 5:54 pm

Re: queue.Queue problem

Postby stranac » Sun Nov 17, 2013 9:26 pm

You don't want to use a Queue.Queue here, this is not what that's meant for.

I don't really understand your reasons for not using a collections.deque.
Can you show an example of problems you have with it?
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1143
Joined: Thu Feb 07, 2013 3:42 pm

Re: queue.Queue problem

Postby abhi1988srivastava » Sun Nov 17, 2013 11:54 pm

My bad totally..the problem was I was trying to initialize deque with an int which is not iterable so thats why not executing. But then tried to make an empty deque and appended the items and it worked. Sorry I could have tried it before ..thanks for pointing.

Abhinav
abhi1988srivastava
 
Posts: 11
Joined: Mon Sep 09, 2013 5:54 pm


Return to General Coding Help

Who is online

Users browsing this forum: snippsat and 4 guests