This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jiwon
Recipients
Date 2004-03-21.16:59:14
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=595483

Hi, quiver. I don't think we can easily go around this problem 
if we have to capture iterators in generator expression.
If you run following, you'll know what I mean.

>>> a = iter("abcd")
>>> b = iter("abcd")
>>> [(x, y) for x in a for y in b]
[('a', 'a'), ('a', 'b'), ('a', 'c'), ('a', 'd')]

I think one possible solution could be, instead of passing 
evaluations of iterators in generator expression,  make a list 
from iterator and, then pass it as argument. For instance,

g = (x for x in iter("abcd"))

will be equivalent to,

def __gen(_[1]):
    for x in _[1]:
        yield x
g = __gen(list(iter("abcd"))) # see 'list'

- instead of g = __gen(iter("abcd"))  .

I'm not sure if I'm in a position to decide to do that way or 
not. If the current reviewer (rhettinger) approves it, I'll do 
that way. Or else, I think I will post it on the mailing list.
History
Date User Action Args
2007-08-23 15:31:38adminlinkissue872326 messages
2007-08-23 15:31:38admincreate