Help: Have an instance, but can't access its info

Sjoerd Mullender sjoerd at oratrix.nl
Thu May 27 11:20:46 EDT 1999


On Thu, May 27 1999 Robb Shecter wrote:

> Hi,
> 
> I'm having a strange problem, and it'd be great if someone has an
> idea...  I have the following code, which (I believe) returns a "Cookie"
> object:
> 
> db = CookieDB(filename='/path/to/cookies')
> cookie = db.lookup(domain='hostname.de', path='/servlet')
> print cookie
> print cookie.name
> 
> .....and here's the output:
> 
> [<cookielib.Cookie instance at 80f0e68>]
> Traceback (innermost last):
>   File "<stdin>", line 15, in ?
> AttributeError: name

It looks like you get a *list* of cookies, so try printing
cookie[0].name (and of course you should make sure that there are
elements in the list).

-- Sjoerd Mullender <sjoerd.mullender at oratrix.nl>




More information about the Python-list mailing list