what's the difference between pycurl.WRITEFUNCTION and pycurl.WRITEDATA?

StackOverflow https://stackoverflow.com/questions/17941212

  •  04-06-2022
  •  | 
  •  

سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top