RFC: Proposal: Deterministic Object Destruction

Ooomzay ooomzay at gmail.com
Sat Mar 3 21:28:49 EST 2018


On Friday, 2 March 2018 15:37:25 UTC, Paul  Moore  wrote:
[snip]
>     def fn():
>         for i in range(10000):
>             with open(f"file{i}.txt", "w") as f:
>                 f.write("Some text")
> 
> How would you write this in your RAII style - without leaving 10,000
> file descriptors open until the end of the function?
 
    def fn():
        for i in range(10000):
            f = RAIIFile(f"file{i}.txt", "w")
            f.write("Some text")



More information about the Python-list mailing list