Equivalent to Python with Statement

phongkhamdakhoathegioi thanhbinh04101988 at gmail.com
Sat Mar 3 09:24:09 UTC 2018


On Thursday, 1 March 2018 at 07:34:38 UTC, Cym13 wrote:
> On Wednesday, 28 February 2018 at 22:55:19 UTC, Seb wrote:
>> On Wednesday, 28 February 2018 at 21:47:40 UTC, Cym13 wrote:
>>> [...]
>>
>> I know that I am repeating myself, but manually closing the 
>> file isn't needed in D. It's refCounted and will be closed 
>> automatically once the scope is left. That's why 
>> `with(File("AAA","w"))` works in D.
>
> As stated, yes that's an accurate answer to that particular 
> problem and it's well understood, I'm just giving a more 
> general answer that will work for every python context manager 
> and not only on the  specific case of closing files.

http://phongkhamdakhoathegioi.vn/u-nang-buong-trung-dang-nuoc.html


More information about the Digitalmars-d-learn mailing list