+ 1

Why using a variable?

Writing file=open(....), I don't get what kind if variable "file" is, and why it helps to close file instead of, say, close("file.txt") or something like this. Do you then modify the content of a variable?! Is it used as an implicit pointer? Oo

27th Jun 2016, 8:04 AM
Jib
1 Answer
+ 1
open return a file object (see POO chapter). The type of file is then and object of the class file. That is why you always use method of this object : file.read(), file.close()...
1st Jul 2016, 9:11 PM
samuel delepoulle
samuel delepoulle - avatar