Message45182
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. |
|
Date |
User |
Action |
Args |
2007-08-23 15:31:38 | admin | link | issue872326 messages |
2007-08-23 15:31:38 | admin | create | |
|