Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'assign': 0.04; 'subject:module': 0.04; 'variable,': 0.07; 'am,': 0.12; 'skip:[ 20': 0.12; 'subject:file': 0.12; 'received:209.85.214.174': 0.13; 'expression.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:named': 0.16; 'wrote:': 0.18; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'sat,': 0.25; 'module': 0.26; 'variable': 0.28; 'message-id:@mail.gmail.com': 0.28; '24,': 0.29; 'temporary': 0.29; 'skip:( 20': 0.31; 'received:209.85.214': 0.32; 'it?': 0.33; 'to:addr:python-list': 0.34; 'received:google.com': 0.37; 'some': 0.38; 'received:209.85': 0.38; 'skip:o 20': 0.38; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'subject:Get': 0.71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=8GmDaiBSdguQRvC1l7JlOxBXPeTkcyWo3ybAonWWbWU=; b=Z4t6VAEe3oqs+W6gADdaJ+zLtKJhjHUsQtk6NS/DcZBtudQ/eSAuexW3I0nXcX0Hwo gVetlwyoFAT46fXkZPanK6Rjf+5W2Rm48Mw8Co7xH2iOaaFQvXOXzj38qPVMv0yeug3f o5cfDBhhDWFagzIh6AyuETHRcaGL16gm8SwcQ= MIME-Version: 1.0 In-Reply-To: <4652751.858.1324669248908.JavaMail.geo-discussion-forums@prj1> References: <32472953.855.1324656114851.JavaMail.geo-discussion-forums@prix23> <4946660.379.1324659073535.JavaMail.geo-discussion-forums@prez5> <4652751.858.1324669248908.JavaMail.geo-discussion-forums@prj1> Date: Sat, 24 Dec 2011 06:52:22 +1100 Subject: Re: Get named module's file location From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324669945 news.xs4all.nl 6898 [2001:888:2000:d::a6]:38145 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17823 On Sat, Dec 24, 2011 at 6:40 AM, Gnarlodious wrote: > [(imp.find_module(module)[1], os.path.getmtime(imp.find_module(module)[1])) for module in modules] > > Can I in some way assign imp.find_module(module)[1] to a variable and reuse it? Is this a job for lambda? Well, you can use an additional comprehension to provide a temporary variable, if you really want to do it all as a single expression. [(m, os.path.getmtime(m)) for m in (imp.find_module(module)[1] for module in modules)] ChrisA