Hi, I am trying to understand how and when iterator expressions get evaluated. The following seems to be a lazy expression:
g = (i for i in range(1000) if i % 3 == i % 2)
This one, however fails on construction:
g = (line.strip() for line in open('xxx', 'r') if len(line) > 10)
I do not have the file named 'xxx'. However, since this thing is lazy, why is it failing so soon?
Thanks.
EDI: Wow, I made a lazy one!
g = (line.strip() for i in range(3) for line in open(str(i), 'r'))