Skip to content

Instantly share code, notes, and snippets.

@chomy
Last active December 27, 2015 20:49
Show Gist options
  • Select an option

  • Save chomy/7387447 to your computer and use it in GitHub Desktop.

Select an option

Save chomy/7387447 to your computer and use it in GitHub Desktop.
test of pycurl using closure
def gen_write_handler(filename):
f = open(filename, 'w')
def write(buff):
f.write(buff)
def close():
f.close()
return (write, close)
write_handler,close_file = gen_write_handler('test.txt')
c = pycurl.Curl()
c.setopt(pycurl.URL, 'http://www.yahoo.co.jp')
c.setopt(pycurl.WRITEFUNCTION, write_handler)
c.perform()
c.close()
close_file()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment