On Fri, 23 Dec 2011 15:00:17 -0500, Roy Smith wrote:
>> Can I in some way assign imp.find_module(module)[1] to a variable and
>> reuse it? Is this a job for lambda?
>
> I think what you want to do is rewrite the list comprehension as a
> regular loop.
>
> my_list = []
> for module in modules:
>
I'm guessing you meant for this to be on-list, and am hoping you don't
mind that I'm replying on-list.
On Sat, Dec 24, 2011 at 8:16 AM, Gnarlodious wrote:
> Chris Angelico wrote:
>> [(m, os.path.getmtime(m)) for m in (imp.find_module(module)[1] for
>> module in modules)]
>>
>> Yeah, a little hard
In article
<4652751.858.1324669248908.JavaMail.geo-discussion-forums@prj1>,
Gnarlodious wrote:
> I am rolling my own, and learning Python at the same time.
Hmmm. The imp module is kind of deep magic for a first introduction to
the language. But, whatever.
> One more question. Say I want to
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 additio
I am rolling my own, and learning Python at the same time.
One more question. Say I want to assemble a list of tuples like this:
modules = ['wsgiref', 'http']
import imp
[(imp.find_module(module)[1], os.path.getmtime(imp.find_module(module)[1])) for
module in modules]
Can I in some way assign i
In article
<4946660.379.1324659073535.JavaMail.geo-discussion-forums@prez5>,
Gnarlodious wrote:
> Roy Smith wrote:
>
> > import imp
> > imp.find_module()
>
> Oh yeah that works. I am getting a list of modtimes using List Comprehension,
> from a list of modules, which will be compared to an o
Roy Smith wrote:
> import imp
> imp.find_module()
Oh yeah that works. I am getting a list of modtimes using List Comprehension,
from a list of modules, which will be compared to an older list to see if
mod_wsgi needs to be restarted.
Maybe thee is an easy way to get the modtimes, I'd be gratef
In article
<32472953.855.1324656114851.JavaMail.geo-discussion-forums@prix23>,
Gnarlodious wrote:
> Given a module's name, how do I get the file path without importing it?
> Searched all over, can't find any such info.
>
> Is it possible to ask if a named module exists before attempting an im
>>> import imp
>>> imp.find_module("os")
(,
'/usr/lib/python2.7/os.py', ('.py', 'U', 1))
>>>
2011/12/23 Gnarlodious
> Given a module's name, how do I get the file path without importing it?
> Searched all over, can't find any such info.
>
> Is it possible to ask if a named module exists before a
Given a module's name, how do I get the file path without importing it?
Searched all over, can't find any such info.
Is it possible to ask if a named module exists before attempting an import?
Or are we forced to import first and catch any failure?
-- Gnarlie
--
http://mail.python.org/mailman/
10 matches
Mail list logo