Please tell me how to bulk set up pycurl options from dictionary.
Example:
options = {
'WRITEFUNCTION': buffer.write,
'FOLLOWLOCATION': True,
'HEADER': True,
'VERBOSE': False,
}
options2 = {
'COOKIEFILE': cookie_file,
'COOKIEJAR': cookie_file,
}
options.update(options2)
and i need something like that:
for opt, val in options.items():
curl.setopt(pycurl.opt, val)
thank you in advance!
You can just use Python's getattr method. The start would be the same as yours and then
for opt, val in options.items():
curl.setopt(getattr(curl,opt), val)