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


Groups > comp.lang.python > #17823

Re: Get named module's file location

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 <rosuav@gmail.com>
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> <roy-533975.11181223122011@news.panix.com> <4946660.379.1324659073535.JavaMail.geo-discussion-forums@prez5> <roy-4780C2.11564723122011@news.panix.com> <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 <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4038.1324669945.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sat, Dec 24, 2011 at 6:40 AM, Gnarlodious <gnarlodious@gmail.com> 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

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


Thread

Get named module's file location Gnarlodious <gnarlodious@gmail.com> - 2011-12-23 08:01 -0800
  Re: Get named module's file location Roy Smith <roy@panix.com> - 2011-12-23 11:18 -0500
    Re: Get named module's file location Gnarlodious <gnarlodious@gmail.com> - 2011-12-23 08:51 -0800
      Re: Get named module's file location Roy Smith <roy@panix.com> - 2011-12-23 11:56 -0500
        Re: Get named module's file location Gnarlodious <gnarlodious@gmail.com> - 2011-12-23 11:40 -0800
          Re: Get named module's file location Chris Angelico <rosuav@gmail.com> - 2011-12-24 06:52 +1100
            Re: Get named module's file location Chris Angelico <rosuav@gmail.com> - 2011-12-24 08:21 +1100
          Re: Get named module's file location Roy Smith <roy@panix.com> - 2011-12-23 15:00 -0500
            Re: Get named module's file location Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-23 22:39 +0000

csiph-web