Talk:Python Programming/Files

Using with statement
I don't believe "with" should be the default manner of opening files presented. It looks more syntactically complicated and does not seem to be necessary in most circumstances. Claims to the effect that the use of with is critical or the like needs a good substantiation and be empirically verifiable, I believe, before the simple idiom

for line in open(file): do things with line

is replaced with something more complicated. My expectation is that file handles are automatically closed when they leave their scope.

Furthermore, "with" was only introduced in Python 2.5; some places are using older versions of Python for various purposes. --Dan Polansky (discuss • contribs) 13:25, 22 November 2015 (UTC)