should I transfer 'iterators' between functions?

seaspeak at gmail.com seaspeak at gmail.com
Sat Jan 25 01:37:37 EST 2014


take the following as an example, which could work well.
But my concern is, will list 'l' be deconstructed after function return? and then iterator point to nowhere?

def test():
    l = [1, 2, 3, 4, 5, 6, 7, 8]
    return iter(l)
def main():
    for i in test():
        print(i)
   



More information about the Python-list mailing list