OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)


On Friday, March 2, 2018 at 1:59:02 AM UTC, Lawrence D?Oliveiro wrote:
> On Friday, March 2, 2018 at 1:03:08 PM UTC+13, ooo... at gmail.com wrote:
> > On Thursday, March 1, 2018 at 11:51:50 PM UTC, Lawrence D?Oliveiro wrote:
> >> On Friday, March 2, 2018 at 12:39:01 PM UTC+13, ooo... at gmail.com wrote:
> >>>
> >>> class RAIIFileAccess():
> >>>     '''File Access-like Resource using [RAII] idiom'''
> >>> ...
> >>>     def __del__(self):        
> >>>         low_level_file_close(self.handle) # fictitious function
> >> 
> >> This may be OK for files opening for reading, not so good for writing.
> > 
> > Please could you explain the issue you perceive with writing?
> 
> Compare the difference in behaviour between
> 
>     f = open("/dev/full", "w")
>     f.write("junk")
>     f.close()
> 
> and
> 
>     f = open("/dev/full", "w")
>     f.write("junk")
>     f = None
> 
> Should there be a difference in behaviour?

Could you please be very explicit about why you think the PEP would be more suitable when reading a file than when writing a file? You have responded with another question that I just can't see the relevance of (yet).