Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28750
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cameron@cskk.homeip.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'intermediate': 0.05; 'strings.': 0.07; "subject:' ": 0.07; 'iterate': 0.09; 'str)': 0.09; 'tuple': 0.09; 'cc:addr:python-list': 0.10; 'enough.': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'guessing': 0.16; 'iterable,': 0.16; 'list)': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'nesting': 0.16; 'plural,': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:edu.au': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'roy': 0.16; 'simpson': 0.16; 'somewhere.': 0.16; 'structures,': 0.16; 'subject:object': 0.16; 'string': 0.17; 'wrote:': 0.17; 'supposed': 0.21; 'converted': 0.22; 'work,': 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'looks': 0.26; 'skip:[ 10': 0.26; 'first,': 0.27; 'plain': 0.27; 'possibility': 0.27; 'converting': 0.27; 'structures': 0.27; 'subject:list': 0.28; 'accidentally': 0.29; 'assert': 0.29; 'lists?': 0.29; 'strings,': 0.29; 'case,': 0.29; 'character': 0.29; "i'm": 0.29; 'usually': 0.30; 'error': 0.30; 'expect': 0.31; 'lists': 0.31; 'problem.': 0.32; 'suggestion': 0.32; 'print': 0.32; 'getting': 0.33; 'certain': 0.33; 'like:': 0.33; 'code:': 0.33; 'themselves': 0.33; 'another': 0.33; 'wrong': 0.34; 'list': 0.35; 'sequence': 0.35; 'too.': 0.35; 'something': 0.35; 'but': 0.36; 'be.': 0.36; 'received:au': 0.36; "i'll": 0.36; 'too': 0.36; 'charset:us-ascii': 0.36; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:l 20': 0.38; 'things': 0.38; 'instead': 0.39; 'build': 0.39; 'list,': 0.39; 'skip:" 10': 0.40; 'end': 0.40; 'think': 0.40; 'your': 0.60; 'easy': 0.60; 'content- disposition:inline': 0.60; 'most': 0.61; 'more.': 0.62; 'more': 0.63; 'making': 0.64; 'taking': 0.65; 'life': 0.66; 'fact,': 0.69; 'smith': 0.71; 'subject:skip:A 10': 0.75; 'article': 0.78 |
| Date | Sun, 9 Sep 2012 09:26:46 +1000 |
| From | Cameron Simpson <cs@zip.com.au> |
| To | Roy Smith <roy@panix.com> |
| Subject | Re: AttributeError: 'list' object has no attribute 'lower' |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| In-Reply-To | <roy-838395.13453908092012@news.panix.com> |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| References | <roy-838395.13453908092012@news.panix.com> |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.395.1347146810.27098.python-list@python.org> (permalink) |
| Lines | 53 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1347146810 news.xs4all.nl 6931 [2001:888:2000:d::a6]:34110 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:28750 |
Show key headers only | View raw
On 08Sep2012 13:45, Roy Smith <roy@panix.com> wrote: | First, I don't understand this code: | | In article <df7ab5f7-c273-4a62-b79a-f364f9c2d3b0@googlegroups.com>, | Token Type <typetoken@gmail.com> wrote: | > synset_list = list(wn.all_synsets(pos)) | > lemma_list = [synset.lemma_names for synset in synset_list] | | It looks like you're taking an iterable, converting it to a list, just | so you can iterate over it again. Why not the simpler: | | > lemma_list = [synset.lemma_names for synset in wn.all_synsets(pos)] Speaking for myself, when I write something like that it is because I need to iterate over it twice or more. Often I'll make a tuple instead of a list in that case, too, to avoid certain types of accidents. | ? But, I'm also confused about what lemma_list is supposed to end up | being. The name "lemma_names" is plural, making me think it returns a | list of something. And then you build those up into a list of lists? | | In fact, I'm guessing that's your problem. I think you're ending up | with a list of lists of strings, when you think you're getting a list of | strings. In my case, I have most often had this error (<list>.lower or its equivalent) when I've accidentally converted a string into a list of characters; easy to do because strings are themselves iterables, yielding a sequence of single character strings:-) It is usually an accident from getting my nesting wrong somewhere. | My suggestion is to print out all the intermediate data structures | (synset_list, lemma_list, etc) and see what they look like. If the | structures are simple, just plain print will work, but for more | complicated structures, pprint.pprint() is a life saver. | | Another possibility is to assert that things are what you expect them to | be. Something like: | | assert isinstance(synset_list, list) | assert isinstance(lemma_list, list) | assert isinstance(lemma_list[0], str) | | and so on. +1 to all of this, too. Cheers, -- Cameron Simpson <cs@zip.com.au> Too much of a good thing is never enough. - Luba
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
AttributeError: 'list' object has no attribute 'lower' Token Type <typetoken@gmail.com> - 2012-09-08 10:13 -0700
wordnet NLTK Re: AttributeError: 'list' object has no attribute 'lower' Token Type <typetoken@gmail.com> - 2012-09-08 10:32 -0700
Re: AttributeError: 'list' object has no attribute 'lower' Roy Smith <roy@panix.com> - 2012-09-08 13:45 -0400
Re: AttributeError: 'list' object has no attribute 'lower' Cameron Simpson <cs@zip.com.au> - 2012-09-09 09:26 +1000
Re: AttributeError: 'list' object has no attribute 'lower' Token Type <typetoken@gmail.com> - 2012-09-09 06:50 -0700
Re: AttributeError: 'list' object has no attribute 'lower' Roy Smith <roy@panix.com> - 2012-09-09 10:29 -0400
Re: AttributeError: 'list' object has no attribute 'lower' Token Type <typetoken@gmail.com> - 2012-09-09 07:00 -0700
Re: AttributeError: 'list' object has no attribute 'lower' Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-09-10 11:52 +0200
Re: AttributeError: 'list' object has no attribute 'lower' Token Type <typetoken@gmail.com> - 2012-09-14 08:01 -0700
Re: AttributeError: 'list' object has no attribute 'lower' Chris Angelico <rosuav@gmail.com> - 2012-09-15 01:19 +1000
Re: AttributeError: 'list' object has no attribute 'lower' Token Type <typetoken@gmail.com> - 2012-09-14 08:01 -0700
Re: AttributeError: 'list' object has no attribute 'lower' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-14 15:18 +0000
Re: AttributeError: 'list' object has no attribute 'lower' Token Type <typetoken@gmail.com> - 2012-09-09 07:19 -0700
Re: AttributeError: 'list' object has no attribute 'lower' Roy Smith <roy@panix.com> - 2012-09-09 10:32 -0400
csiph-web