How can Python print the value of an attribute but complain it does not exist?
Karen Tracey
kmtracey at gmail.com
Wed Oct 10 15:36:39 EDT 2007
On 10/10/07, Emre Sevinc <emre.sevinc at gmail.com> wrote:
[snip]
$ python generatefeedvector-debug.py
> Signal vs. Noise
> Traceback (most recent call last):
> File "generatefeedvector-debug.py", line 37, in ?
> title = getwordcounts(feedurl)
> File "generatefeedvector-debug.py ", line 21, in getwordcounts
> print d.feed.title
> File "/var/lib/python-support/python2.4/feedparser.py", line 236, in
> __getattr__
> raise AttributeError, "object has no attribute '%s'" % key
> AttributeError: object has no attribute 'title'
>
>
> The strange thing is that it DOES print the value d.feed.title then
> complains AttributeError: object has no attribute 'title'. What am I
> doing wrong?
>
> The file feedlist1-2.txt includes just a single line:
>
> $ cat feedlist1-2.txt
> http://feeds.feedburner.com/37signals/beMH
I'll bet your feedlist1-2.txt file has a blank line at the end. Your
program is printing the title for the first line and then choking when you
try to retrieve the title for the blank line.
Karen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071010/1f1496fb/attachment.html>
More information about the Python-list
mailing list