On 1/26/12 3:20 PM, amt wrote:
Exercise 17, extra credit 6 Learn python the hard way: Find out why
you had to do output.close() in the code.


Code:

output.close()
input.close()


I don't get it. If you don't close input and output it works exactly
the same as if you would close them, so why do you have to do
output.close() and input.close()?

Also does it matter if you do: input.close() and then output.close()?
Is there an order to follow?

There's no order to follow, and it's really more about cleaning up after yourself than being a necessity. If you were writing to real files, your operating system would limit how many open files you could have at any time, so you want to make sure you close file handles you're no longer using.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to