RFC: Proposal: Deterministic Object Destruction

ooomzay at gmail.com ooomzay at gmail.com
Thu Mar 1 19:07:06 EST 2018


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


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /