On Fri, Mar 2, 2018 at 11:07 AM, <ooom...@gmail.com> wrote: > On Thursday, March 1, 2018 at 11:59:26 PM UTC, Chris Angelico wrote: >> On Fri, Mar 2, 2018 at 10:38 AM, ooomzay wrote: >> > def raii_example(): >> > >> > src = RAIIFileAccess("src.txt", 'r') >> > dst = RAIIFileAccess("dst.txt", 'w') >> > >> > for line in src: >> > dst.write(line) >> >> What happens if we make this change? >> >> def raii_example(): >> global dst >> src = RAIIFileAccess("src.txt", 'r') >> dst = RAIIFileAccess("dst.txt", 'w') >> >> for line in src: >> dst.write(line) >> >> When does the destination file get closed? > > When you execute:- > > del dst > > or:- > > dst = something_else >
What if you don't? ChrisA -- https://mail.python.org/mailman/listinfo/python-list