[Samuele Pedroni]
From: "Samuele Pedroni"
you're right, you would also get this idiom for iterators that support also
the
'with' protocol:
with myfile = auto_closing_file('blah.txt', 'rb'): for line in myfile: ...
With Guido's 'do', you could define an iterclose():
do iterclose(open('blah.txt','rb')): (line): ...
Could we possibly flesh out both of these examples to what would amount to working code (including code that would manipulate what they create by searching for "Python" in each line) in a single email? I would like to make sure that I am comprehending how this will all work in the end. So if someone (read: Guido and Samuele =) could implement a file that auto-closes once the iterator on the file is exhausted with each suggestion I would *really* appreciate it. And if there could even be code given that used what these things returned by searching each returned line for the word "Python" would be great as well. That way we not only see how the new syntax would work, but we also see how code is going to interface with what the new code generates. -Brett