pythonbrowsermechanizecookielib

.set_function ---- is this method or anything?


sorry for poor english. I'm now reading python's cookbook and trying to mechanize. then,there are codes I can't understand. this:mechanize

import mechanize
def printCookies(url):
browser = mechanize.Browser()
cookie_jar = cookielib.LWPCookieJar()
browser.set_cookiejar(cookie_jar)
<skipped>

well.... in "browser.set_cookiejar(cookie_jar)", what ".set_cookiejar(cookie_jar)" does?

I think browser and cookie_jar are instance. then,at the thought of it, browser.set_cookiejar(cookie_jar) meaning I insert instance into anoher instance....????? my brain is about to overflow.


Solution

  • It calls the set_cookiejar method of the object bound to browser, passing it the object in cookie_jar as the first supplied argument. What does that method do? Well, that's what the library documentation is for.