0

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.

ilp2bwlp3
  • 3
  • 2
  • You may find this helpful http://stackoverflow.com/questions/15459217/how-to-set-cookie-in-python-mechanize – COCO Nov 07 '15 at 09:20

1 Answers1

0

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.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358