[Tutor] build list of non-empty variables

Alan Gauld alan.gauld at btinternet.com
Wed Jul 9 20:20:35 CEST 2008

"Don Jennings" <dfjennings at gmail.com> wrote

>> return ';'.join(x for x in l if x)

> Ah! A list comprehension. Not at that point in the learning python 
> book,

Not quite, I believe its called a generator expression. Its like
a list comprehension but without the [] around it.

In fact I guess you could say that the new definition of a list
comprehension is

[ generator expression]

But if I'm wrong someone will explain why I'm sure! :-)

Alan G.

More information about the Tutor mailing list