Closing Files
# Open files consume system resources, and depending on the file mode,
# other programs may not be able to access them.
# It's important to close files as soon as you're finished with them, as shown in
#
f = open("/music/_singles/kairo.mp3", "rb")
print f.closed
f.close()
print f
print f.closed
# The closed attribute of a file object indicates whether the object has
# a file open or not. In this case, the file is still open (closed is False).
Related examples in the same category