In http://docs.python.org/library/json.html:
simplejson.load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_
In Python, a file object is an object exposing an API having methods for performing operations typically done on files, such as read()
or write()
.
In the question's example: simplejson.load(fp, ...)
, the object passed as fp
is only required to have a read()
method, callable in the same way as a read()
on a file (i.e. accepting an optional parameter size
and returning either a str
or a bytes
object).
This does not need to be a real file, though, as long as it has a read()
method.
A file-like object is just a synonym for file-object. See Python Glossary.