On Sat, Jan 25, 2014 at 5:37 PM,  <seasp...@gmail.com> wrote:
> 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)

Perfectly safe. Python guarantees that nothing can ever point to
"nowhere"; everything that might be looking for something else will
hold a reference to it, so the thing referred to will hang around.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to