[Tutor] Cookielib - CookieJar objects

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jun 29 08:21:49 CEST 2005



On Wed, 29 Jun 2005, Peter Szinek wrote:

> Hello Denise,
>
> How about this:
>
> myjar = cookielib.CookieJar()
> for cookie in myjar:
>      print cookie.value
>
> In this case the above code should print a single 'B'.


Yes, whenever the documentation talks about something being "iterable",
they really mean that we can use a for loop across it.  It does seem a
little odd that this appears to be a primary way to access the cookies in
a cookie jar:

    http://www.python.org/doc/lib/node534.html

I wonder why; I haven't been able to figure out a good reason for this
kind of interface.  Are cookie jars files known to be large?

I do hope it's not a matter of preserving the metaphor of reaching into a
cookie jar to grab cookies one at a time... *grin*



More information about the Tutor mailing list