Last active
December 27, 2015 20:49
-
-
Save chomy/7387447 to your computer and use it in GitHub Desktop.
test of pycurl using closure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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