In article <4652751.858.1324669248908.JavaMail.geo-discussion-forums@prj1>, Gnarlodious <gnarlodi...@gmail.com> 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 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? I think what you want to do is rewrite the list comprehension as a regular loop. my_list = [] for module in modules: m = imp.find_module(module)[1] my_list.append(m, os.path.getmtime(m)) -- http://mail.python.org/mailman/listinfo/python-list