why does the following with Queue, q.put('\x02', True) not put itin the queue?

G

Gabriel Rossetti

Hello,

I'm having some trouble with the Queue class, for some reason, if I do
this (ch == ) :

q = Queue.Queue(0)
repr(ch)
q.put(ch, True)
len(q.queue)

where the output is :

'\x02'
0

why isn't the character/string being put it in the queue?

Thank you,
Gabriel
 
S

sturlamolden

Hello,

I'm having some trouble with the Queue class, for some reason, if I do
this (ch == ) :

q = Queue.Queue(0)
repr(ch)
q.put(ch, True)
len(q.queue)
1
 
G

Gabriel Rossetti

Arimaz SA
Av. du 24 Janvier 11
Ateliers de la Ville de Renens, Atelier 5
1020 Renens, Switzerland
www.mydeskfriend.com
Mob: +41-(0)79-539-0069
Tel: +41-(0)21-566-7343


yes, if you do it that way (s = '\x02') it works, but I read the data
from a file, and I that way it doesn't work....
 
J

Jerry Hill

yes, if you do it that way (s = '\x02') it works, but I read the data from
a file, and I that way it doesn't work....

It does work (using Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45)
[MSC v.1310 32 bit (Intel)] on win32)

import Queue
f = open('temp', 'w')
f.write('\x02')
f.close()

f = open('temp', 'r')
ch = f.read(1)
f.close()

print repr(ch)
q = Queue.Queue(0)
q.put(ch, True)
print len(q.queue)

prints the following:
'\x02'
1

Perhaps you could put together an example that actually shows the
behavior you're seeing. I'm not super familiar with Queue.Queue
internals, but should you be accessing the undocumented q.queue (the
internal deque of the Queue instance) directly? Shouldn't you be
using the documented q.qsize() interface instead?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,765
Messages
2,569,568
Members
45,042
Latest member
icassiem

Latest Threads

Top