beginer question of list comprehensions

Larry Bates larry.bates at websafe.com
Thu Mar 23 20:50:50 CET 2006


Echo wrote:
> Ok, this is the first list comprehension that I have done.
> Surprisinly, it works for the most part.
> The problem with it is that it returns a list with two lists in it,
> instead of just one list. Can anyone tell me what I am doing wrong or
> how to fix it.
> 
> Here is my code:
> [t for t in (__import__(m, globals(), locals(), m).BizObjects() for m
> in table_files)]
> 
> "table_files" is a list with two module names
> "__import__(m, globals(), locals(), m).BizObjects()" is a list of
> objects gotten from the module.
> 
> --
> -Echo

I think you meant to write:

[t for t in __import__(m, globals(), locals(), m).BizObjects() for m
 in table_files]

-Larry Bates



More information about the Python-list mailing list