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:
>    m = imp.find_module(module)[1]
>    my_list.append(m, os.path.getmtime(m))

+1


List comprehensions are so cool that sometimes people forget that not 
every loop has to be a list comp. There is no shortage of newlines in the 
world, and not everything needs to be on a single line.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to