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: 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: References: Date: Mon, 22 Dec 2014 17:06:37 +1100 Subject: Re: List Comprehensions From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Mon, Dec 22, 2014 at 4:42 PM, Ganesh Pal 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