I just want to know the difference of the following two statements:
curl.setopt(pycurl.WRITEDATA, fp)
curl.setopt(pycurl.WRITEFUNCTION, fp.write)
fp is a file descriptor, and fp.write is a function. Could anybody tell me?
With the WRITEDATA
callback option, you can control which file the default WRITEFUNCTION
callback writes to.
The function set with the WRITEFUNCTION
option is the one which is actually called as soon as there is data received that needs to be saved.
Normally, the value you specify to WRITEDATA
will be passed to the WRITEFUNCTION
callback, but in PyCurl, the WRITEFUNCTION
callback just takes a single string as argument, so there's not much use in using WRITEDATA
with WRITEFUNCTION
together in PyCurl.