[Python-ideas] Statements vs Expressions... why?
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Sep 16 07:58:50 CEST 2008
Cliff Wells wrote:
> Actually, I think I see the issue. join() is getting a list of
> iterators (using list notation for simplicity):
>
> '-'.join ( [ [ 's','p','a','m'], ['e','g','g','s'] ] )
>
> Is this the conclusion you were coming to or something else?
Yes, that's right. Arnaud's original code is a single
generator containing two nested loops, whereas your
version consists of two nested generators.
I think your first translation would have produced
the right result, because it iterated over each of
the inner generators and re-yielded their results
in the outer generator. But that's a very expensive
way of going about it.
--
Greg
More information about the Python-ideas
mailing list