Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60861

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'attribute': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tismer': 0.09; 'python': 0.11; 'attribute:': 0.16; 'btw': 0.16; 'really?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skipping': 0.16; 'language': 0.16; 'wrote:': 0.18; 'meant': 0.20; '>>>': 0.22; 'programming': 0.22; 'import': 0.22; 'header :User-Agent:1': 0.23; 'received:comcast.net': 0.24; "shouldn't": 0.24; 'subject:like': 0.24; 'second': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'directly,': 0.31; 'doc': 0.31; 'subject:with': 0.35; 'but': 0.35; 'add': 0.35; 'described': 0.36; 'should': 0.36; 'list': 0.37; 'christian': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject: ': 0.61; 'world.': 0.61; 'first': 0.61; ',the': 0.84; '8bit%:61': 0.84; 'directly.': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: how to implement a queue-like container with sort function
Date Mon, 02 Dec 2013 06:58:11 -0500
References <b5e67d65-76a4-4a1a-87b4-70402c9bf865@googlegroups.com> <0c445e44-25c7-42b9-8c62-c30428261251@googlegroups.com> <mailman.3400.1385737072.18130.python-list@python.org> <39b48b0b-5c0a-42d9-922f-27987386764b@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host c-50-133-228-126.hsd1.ma.comcast.net
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.1.1
In-Reply-To <39b48b0b-5c0a-42d9-922f-27987386764b@googlegroups.com>
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.3458.1385985503.18130.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385985503 news.xs4all.nl 15920 [2001:888:2000:d::a6]:58583
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60861

Show key headers only | View raw


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 attribute 'queue'
>>
>>
>>
>> --
>>
>> Python is the second best programming language in the world.
>>
>> But the best has yet to be invented.  Christian Tismer
>>
>>
>>
>> Mark Lawrence
>
> you can do a check by hasattr()
>

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.  In particular, if you use it directly, 
you are skipping all synchronization, which is the main reason to use a 
Queue in the first place.

It should have been named "_queue". We'll add that to the list of PEP-8 
violations in the Queue module! :)

--Ned.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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