Re: how to implement a queue-like container with sort function

2013-12-03 Thread iMath
在 2013年12月4日星期三UTC+8上午7时23分49秒,Cameron Simpson写道: > On 03Dec2013 16:34, Ned Batchelder wrote: > > > On 12/3/13 4:19 PM, Cameron Simpson wrote: > > > >And then I check the source:-( He actually said "I want to a fixed > > > >length list-like container". That still sounds like a limit to the > >

Re: how to implement a queue-like container with sort function

2013-12-03 Thread Cameron Simpson
On 03Dec2013 16:34, Ned Batchelder wrote: > On 12/3/13 4:19 PM, Cameron Simpson wrote: > >And then I check the source:-( He actually said "I want to a fixed > >length list-like container". That still sounds like a limit to the > >number of entries. > > Sorry, I was unclear. When I said, "I don't

Re: how to implement a queue-like container with sort function

2013-12-03 Thread Ned Batchelder
On 12/3/13 4:19 PM, Cameron Simpson wrote: On 04Dec2013 08:17, I wrote: On 02Dec2013 07:26, Ned Batchelder wrote: Actually, I had a long conversation in the #python IRC channel with the OP at the same time he was posting the question here, and it turns out he knows exactly how many entries are

Re: how to implement a queue-like container with sort function

2013-12-03 Thread Cameron Simpson
On 04Dec2013 08:17, I wrote: > On 02Dec2013 07:26, Ned Batchelder wrote: > > Actually, I had a long conversation in the #python IRC channel with > > the OP at the same time he was posting the question here, and it > > turns out he knows exactly how many entries are going into the > > "queue", so a

Re: how to implement a queue-like container with sort function

2013-12-03 Thread Cameron Simpson
On 02Dec2013 07:26, Ned Batchelder wrote: > Actually, I had a long conversation in the #python IRC channel with > the OP at the same time he was posting the question here, and it > turns out he knows exactly how many entries are going into the > "queue", so a plain-old list is the best solution.

Re: how to implement a queue-like container with sort function

2013-12-02 Thread Ned Batchelder
On 12/2/13 7:04 AM, Chris Angelico wrote: On Mon, Dec 2, 2013 at 10:58 PM, Ned Batchelder wrote: Yes, a Queue object has a queue attribute: >>> import Queue >>> q = Queue.Queue() >>> q.queue deque([]) But you shouldn't use it. It's part of the implementation of Queue, not

Re: how to implement a queue-like container with sort function

2013-12-02 Thread Chris Angelico
On Mon, Dec 2, 2013 at 10:58 PM, Ned Batchelder wrote: > Yes, a Queue object has a queue attribute: > > >>> import Queue > >>> q = Queue.Queue() > >>> q.queue > deque([]) > > But you shouldn't use it. It's part of the implementation of Queue, not > meant for you to use directly.

Re: how to implement a queue-like container with sort function

2013-12-02 Thread Ned Batchelder
On 12/2/13 6:41 AM, iMath wrote: 在 2013年11月29日星期五UTC+8下午10时57分36秒,Mark Lawrence写道: On 29/11/2013 12:33, iMath wrote: BTW ,the Queue object has an attribute 'queue' ,but I cannot find it described in the DOC ,what it means ? Really? AttributeError: type object 'Queue' has no attrib

Re: how to implement a queue-like container with sort function

2013-12-02 Thread iMath
在 2013年11月29日星期五UTC+8下午10时57分36秒,Mark Lawrence写道: > On 29/11/2013 12:33, iMath wrote: > > > > > > BTW ,the Queue object has an attribute 'queue' ,but I cannot find it > > described in the DOC ,what it means ? > > > > > > > Really? AttributeError: type object 'Queue' has no attribute 'queue'

Re: how to implement a queue-like container with sort function

2013-11-29 Thread Mark Lawrence
On 29/11/2013 12:33, iMath wrote: BTW ,the Queue object has an attribute 'queue' ,but I cannot find it described in the DOC ,what it means ? Really? AttributeError: type object 'Queue' has no attribute 'queue' -- Python is the second best programming language in the world. But the best has

Re: how to implement a queue-like container with sort function

2013-11-29 Thread iMath
it seems PriorityQueue satisfy my requirement here . BTW ,the Queue object has an attribute 'queue' ,but I cannot find it described in the DOC ,what it means ? -- https://mail.python.org/mailman/listinfo/python-list

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Cameron Simpson
On 28Nov2013 18:04, iMath wrote: > All in all,I want to first fill the container, then sort it and process all > the contents in it Automatically? It sounds like an I/O buffer, in the sense that a block buffered output stream does a write on buffer full. Something like this: class Chunkifi

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Gregory Ewing
iMath wrote: the container is similar to queue ,but queue doesn't have a sort function You can use a list as a queue. If you have a list l, then l.append(x) will add an item to the end, and l.pop(0) will remove the first item and return it. Then you just need to check the length of the list b

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Steven D'Aprano
On Fri, 29 Nov 2013 13:03:00 +1100, Chris Angelico wrote: > On Fri, Nov 29, 2013 at 12:54 PM, iMath wrote: >> the container is similar to queue ,but queue doesn't have a sort >> function > > It's either a queue that can be sorted, or a list with a length limit. > You could fairly easily impleme

Re: how to implement a queue-like container with sort function

2013-11-28 Thread iMath
hey , you used >>> sorted(a.queue) this means the queue.Queue() has an attribute queue ,but I cannot find it described in the DOC ,where you find it ? -- https://mail.python.org/mailman/listinfo/python-list

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Terry Reedy
On 11/28/2013 8:54 PM, iMath wrote: I want to a fixed length list-like container, it should have a sorted()-like function that I can use to sort it,I think there should also a function I can use it to detect whether the numbers of items in it reaches the length of the container , because if th

Re: how to implement a queue-like container with sort function

2013-11-28 Thread MRAB
On 29/11/2013 01:54, iMath wrote: I want to a fixed length list-like container, it should have a sorted()-like function that I can use to sort it,I think there should also a function I can use it to detect whether the numbers of items in it reaches the length of the container , because if the num

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Chris Angelico
On Fri, Nov 29, 2013 at 1:04 PM, iMath wrote: > All in all,I want to first fill the container, then sort it and process all > the contents in it Where does the length limit come in? By the way, a little context helps a lot with following a thread. ChrisA -- https://mail.python.org/mailman/lis

Re: how to implement a queue-like container with sort function

2013-11-28 Thread iMath
All in all,I want to first fill the container, then sort it and process all the contents in it -- https://mail.python.org/mailman/listinfo/python-list

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Chris Angelico
On Fri, Nov 29, 2013 at 12:54 PM, iMath wrote: > the container is similar to queue ,but queue doesn't have a sort function It's either a queue that can be sorted, or a list with a length limit. You could fairly easily implement either, because in Python, anything can be subclassed. But I think p

how to implement a queue-like container with sort function

2013-11-28 Thread iMath
I want to a fixed length list-like container, it should have a sorted()-like function that I can use to sort it,I think there should also a function I can use it to detect whether the numbers of items in it reaches the length of the container , because if the numbers of items in it reaches the l