Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60749
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.023 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'python,': 0.02; 'discard': 0.07; 'cc:addr:python-list': 0.11; 'block.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'limit.': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'subject:like': 0.24; 'fairly': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'sort': 0.25; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'container': 0.31; 'fri,': 0.33; 'could': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'similar': 0.36; 'so,': 0.37; 'too': 0.37; 'turn': 0.37; 'list': 0.37; 'easily': 0.37; 'implement': 0.38; 'easiest': 0.38; 'nov': 0.38; 'pm,': 0.38; 'anything': 0.39; 'either': 0.39; 'length': 0.61; 'simply': 0.61; 'to:none': 0.92; 'wanting': 0.93; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=LGfdeAkvZGFF54a5FBWjMYboGytt/QeCqoEEBarsvn8=; b=cXUo3Xf8rlYwGG8gneWl6LD17gBeBCZ7twz3f5poidTCJSPM9fswIGv1dEgsv8wkl6 /XFOMqN3guVPeXB8xj0Ow8PYcXdCZ/lL0e8GKdAjYQXajwXaIzmKRTV9eVIlyzBGvLWF VN7V/DAysT80QAmhm13dgblUipd6hBQHBEx/YyR8lkwasPNuw2G2lwzVqSPBnlFqSFgd YUtxc8royQ9KeDvYchkaAcZqA128zCzvgOxr6d1+oQ47OQaFvz7W5nLJ9zgOYVngCHh9 P1VwXBTc2bjcjueTjC5P2RkFgFFRWgkVhLuoJe1qfL0NFoo4p8smSX1nxHjciZfKpAql ROvA== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.148.97 with SMTP id tr1mr24688613pab.163.1385690580362; Thu, 28 Nov 2013 18:03:00 -0800 (PST) |
| In-Reply-To | <b5e67d65-76a4-4a1a-87b4-70402c9bf865@googlegroups.com> |
| References | <b5e67d65-76a4-4a1a-87b4-70402c9bf865@googlegroups.com> |
| Date | Fri, 29 Nov 2013 13:03:00 +1100 |
| Subject | Re: how to implement a queue-like container with sort function |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3389.1385690583.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1385690583 news.xs4all.nl 15880 [2001:888:2000:d::a6]:47585 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:60749 |
Show key headers only | View raw
On Fri, Nov 29, 2013 at 12:54 PM, iMath <redstone-cold@163.com> 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 possibly the easiest way is to simply
turn your queue into a list when you want to work with it:
>>> import queue
>>> a=queue.Queue(10)
>>> a.put("asdf")
>>> a.put("qwer")
>>> a.put("zxcv")
>>> a.put("1234")
>>> sorted(a.queue)
['1234', 'asdf', 'qwer', 'zxcv']
Though I don't know if this is what you meant. Putting too much onto a
queue.Queue will block. Were you wanting it, instead, to discard
entries? If so, which?
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 17:54 -0800
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-11-29 13:03 +1100
Re: how to implement a queue-like container with sort function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-29 03:32 +0000
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 18:04 -0800
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-11-29 13:06 +1100
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 18:32 -0800
Re: how to implement a queue-like container with sort function Cameron Simpson <cs@zip.com.au> - 2013-11-29 17:19 +1100
Re: how to implement a queue-like container with sort function MRAB <python@mrabarnett.plus.com> - 2013-11-29 02:23 +0000
Re: how to implement a queue-like container with sort function Terry Reedy <tjreedy@udel.edu> - 2013-11-28 21:31 -0500
Re: how to implement a queue-like container with sort function Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-11-29 17:53 +1300
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-29 04:33 -0800
Re: how to implement a queue-like container with sort function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-29 14:57 +0000
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-12-02 03:41 -0800
Re: how to implement a queue-like container with sort function Ned Batchelder <ned@nedbatchelder.com> - 2013-12-02 06:58 -0500
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-12-02 23:04 +1100
Re: how to implement a queue-like container with sort function Ned Batchelder <ned@nedbatchelder.com> - 2013-12-02 07:26 -0500
csiph-web