If I read a file file_data = open(...).read()
, I will have "file_data" which refer to data from "read()", and I won't get refer to file a descriptor. It's right? Does this mean that if the file descriptor has 0 links, will it be deleted by the garbage collector? Or file descriptor have 1 link to the opened file and I need to close the file manually?
UPD:
data = open("foo.txt")
# <- brakepoint here
$ lsof foo.txt
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 17249 q 5r REG 8,3 0 1443322 foo.txt
data = open("foo.txt").read()
# <- brakepoint here
$ lsof foo.txt
-