AttributeError: 'list' object has no attribute 'lower'
Roy Smith
roy at panix.com
Sun Sep 9 10:32:33 EDT 2012
In article <dea2fdd1-ad19-4254-b3bf-4104ce0cb241 at googlegroups.com>,
Token Type <typetoken at gmail.com> wrote:
> > structures are simple, just plain print will work, but for more
> >
> > complicated structures, pprint.pprint() is a life saver.
> >
>
> I did try . However,
>
> >>> pprint.pprint(lemma_list)
>
> Traceback (most recent call last):
> File "<pyshell#74>", line 1, in <module>
> pprint.pprint(lemma_list)
> NameError: name 'pprint' is not defined
> >>> pprint.pprint(synset_list)
>
> Traceback (most recent call last):
> File "<pyshell#75>", line 1, in <module>
> pprint.pprint(synset_list)
> NameError: name 'pprint' is not defined
> >>>
OK, I can see how this can be confusing. In "pprint.pprint()", the two
"pprint"s mean different things. The first one is the name of a module.
The second one is the name of a function in that module. In general, I
dislike this style of naming since it just leads to this kind of
confusion.
In any case, you need to do one of two things.
Style 1:
import pprint
pprint.pprint(foo)
Style 2:
from pprint import pprint
pprint(foo)
More information about the Python-list
mailing list