[issue46193] Using a dictionary for open files.

2021-12-29 Thread Keepun
Keepun added the comment: I didn't think about calculating the argument before passing it to the function... -- stage: -> resolved status: open -> closed ___ Python tracker

[issue46193] Using a dictionary for open files.

2021-12-29 Thread Eryk Sun
Eryk Sun added the comment: Every time open(r"test.txt", "w") is called, the existing "test.txt" file gets overwritten in the filesystem as an empty file. For each iteration, setdefault() returns a reference to the first file object, which advances its file pointer with each fh.write("\nHell

[issue46193] Using a dictionary for open files.

2021-12-29 Thread Keepun
New submission from Keepun : """ Using a dictionary for open files. The file is filled with NULL. Only the last entry is normal. Result: 00 00 00 00 ... 00 0A 48 65 6C 6C 6F 0A Ubuntu - 3.8.10 Windows - 3.9.8 """ fhandles = {} for f in range(100): fh = fhandles.setdefault("suffix", open(r