I try such designs:
file = open('file.txt').read() open('copy_file.txt', 'w').write(file) For some reason, everything works ... From the experience of working with other languages, I expected to see some oddities in connection with open streams (I do not close them), but everything works fine. Even with repeated launch. And it doesn't seem like there is a memory leak problem. Why is that ? The documentation did not find anything on this topic ...
textinstead. The file name can be used in Python for the result of calling the open () function. The read () method returns a string, not a file. - jfs