A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2010-March/720334.html below:

Queue peek?

Queue peek? Queue peek?Raymond Hettinger python at rcn.com
Tue Mar 2 13:18:54 EST 2010
On Mar 2, 8:29 am, Veloz <michaelve... at gmail.com> wrote:
> Hi all
> I'm looking for a queue that I can use with multiprocessing, which has
> a peek method.
>
> I've seen some discussion about queue.peek but don't see anything in
> the docs about it.
>
> Does python have a queue class with peek semantics?

Am curious about your use case?  Why peek at something
that could be gone by the time you want to use it.

  val = q.peek()
  if something_i_want(val):
       v2 = q.get()         # this could be different than val

Wouldn't it be better to just get() the value and return if you don't
need it?

  val = q.peek()
  if not something_i_want(val):
      q.put(val)


Raymond




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4