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


Groups > comp.lang.python > #82752

Re: List Comprehensions

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; '(b)': 0.07; '22,': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'cc:addr:python.org': 0.22; '(a)': 0.24; 'fine': 0.24; 'mon,': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'once,': 0.31; 'piece': 0.31; 'probably': 0.32; 'received:google.com': 0.35; 'there': 0.35; 'options:': 0.36; 'subject:List': 0.36; 'doing': 0.36; 'turn': 0.37; 'list': 0.37; 'pm,': 0.38; 'anything': 0.39; 'subject:skip:C 10': 0.61; 'worth': 0.66; 'to:none': 0.92; 'opt': 0.97
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=VCrG/3yhZE8KXA0A/xC3kca4nLVWbq3oO+yK117N8CY=; b=S7ylAP9uSx/LYA+VaLLWsMhz8qOFh9zmZGYRpGhzvij+BSw+LCkt3Ixn50TcD4cdJ/ jRHi6vKP7ZVyN3ObY+o+7twgfb86hC+kCLZBAq5ObebKNMBf4JWt8Q16kPxZJBLJpoRb ejA9sjc2xyI/7A+yMPeQzXL8E6dLM9rA27lCXVwXtTfduvUDL4LY3kaoMG6tTagx8sUd vKGfuuaL4ngdtQdIrHLpPbY6HxbJXAW5NsSU3OLyJXR4VQ8/T56CjR+FImK/36jez/Vv QzEdiQ9/v35GHDlFpeDbSLTV+RpkLl5KTwjJctOfa3fI3UORP/jlbP0k0Dz3o6se5+pB o2yA==
MIME-Version 1.0
X-Received by 10.50.62.104 with SMTP id x8mr14662718igr.2.1419228397698; Sun, 21 Dec 2014 22:06:37 -0800 (PST)
In-Reply-To <CACT3xuWVZPqEZ-hQ6QS7QTnpuBG3FXvVuc=wVN5PLLM7FPrscQ@mail.gmail.com>
References <CACT3xuWVZPqEZ-hQ6QS7QTnpuBG3FXvVuc=wVN5PLLM7FPrscQ@mail.gmail.com>
Date Mon, 22 Dec 2014 17:06:37 +1100
Subject Re: List Comprehensions
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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.17109.1419228400.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1419228400 news.xs4all.nl 2889 [2001:888:2000:d::a6]:42841
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82752

Show key headers only | View raw


On Mon, Dec 22, 2014 at 4:42 PM, Ganesh Pal <ganesh1pal@gmail.com> wrote:
> (a)  I was trying to reduce the below piece of code using List comprehension
> ? Any suggestion please let me know
>
>
>      for opt in options:
>           opt['result'] = Queue.Queue()
>           tmp_thread = pause.Thread(opt)
>           threads.append(tmp_thread)
>            tmp_thread.start()
>
> (b)    Is there anything that I need to consider while using list
> comprehension with threads ?

Your code is doing several things at once, so it's probably not worth
trying to turn it into a comprehension. I don't think it needs to be
shortened, anyway; looks fine to me.

ChrisA

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


Thread

Re: List Comprehensions Chris Angelico <rosuav@gmail.com> - 2014-12-22 17:06 +1100
  Re: List Comprehensions Roy Smith <roy@panix.com> - 2014-12-22 08:07 -0500
    Re: List Comprehensions Chris Angelico <rosuav@gmail.com> - 2014-12-23 00:21 +1100
      Re: List Comprehensions Rustom Mody <rustompmody@gmail.com> - 2014-12-22 06:58 -0800
        Re: List Comprehensions Chris Angelico <rosuav@gmail.com> - 2014-12-23 02:07 +1100
          Re: List Comprehensions Rustom Mody <rustompmody@gmail.com> - 2014-12-22 09:45 -0800

csiph-web