Get named module's file location

Gnarlodious gnarlodious at gmail.com
Fri Dec 23 14:40:48 EST 2011


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 imp.find_module(module)[1] to a variable and reuse it? Is this a job for lambda?

Thanks anyone.

-- Gnarlie



More information about the Python-list mailing list