nbaztec
Master KOD3R
I think yes, but the correct way ought to beHey did i combine these the two lines like the writer wanted?
Code:input = open(from_file) indata = input.read() to indata = open(from_file).read()
Code:
indata = (input=open(from_file)).read();
Make sure the file exists.also it gave an error while closing the file, saying something like that nothing is opened. Can someone explain what the line does?
Free RAM - not exactly. Whenever you open a file you effectively own a resource - A resource that you should release when you are done with it. In scripts/programs you might need to close that file so that other parts of your code (or other programs) can use it since you have acquired a lock to that resource. Also, if you open a file in "write" mode, close() flushes out all buffers in the RAM (since you're actually working on the file in a memory buffer) and begins write to the disk (in simple terms saving your work back to disk).Also what's the need to close the files? To free up RAM? don't the files get closed when the script ends? So, it's only useful when opening big or many files?