question about Generator

chongqing xiao cqxiao at charter.net
Sun Mar 3 10:35:31 EST 2002


Hi,

Suppose if I have a generator (func) which will return [2,4,6,8]

Is any way I can just get the first item (instead of using for x in func()
to get the first item)
or stop before I get the last item in the Generator.
Also, any comments on what the following code will do. (I don't have 2.2
installed so I
can't try it myself)

for x in func():
    for y in func():
        print x,y

Thanks a lot
Chong





More information about the Python-list mailing list