Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28773
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-09-09 06:44 -0700 |
| References | (3 earlier) <C6FCB83691994615873009528A6C0CD7@gmail.com> <CAE5RzXnjE+UqZj5Ofk2i0F=9U7ZGaAi2D+odwZbUHz0_bYQbzg@mail.gmail.com> <mailman.405.1347172371.27098.python-list@python.org> <mailman.407.1347173102.27098.python-list@python.org> <7xwr03oafu.fsf@ruckus.brouhaha.com> |
| Message-ID | <d3107c91-2644-41d1-ba45-1aff0caf59af@googlegroups.com> (permalink) |
| Subject | Re: Is there a unique method in python to unique a list? |
| From | Token Type <typetoken@gmail.com> |
Thanks. I try to use set() suggested by you. However, not successful. Please see:
>>> synsets = list(wn.all_synsets('n'))
>>> synsets[:5]
[Synset('entity.n.01'), Synset('physical_entity.n.01'), Synset('abstraction.n.06'), Synset('thing.n.12'), Synset('object.n.01')]
>>> lemma_set = set()
>>> for synset in synsets:
lemma_set.add(synset.lemma_names)
Traceback (most recent call last):
File "<pyshell#43>", line 2, in <module>
lemma_set.add(synset.lemma_names)
TypeError: unhashable type: 'list'
>>> for synset in synsets:
lemma_set.add(set(synset.lemma_names))
Traceback (most recent call last):
File "<pyshell#45>", line 2, in <module>
lemma_set.add(set(synset.lemma_names))
TypeError: unhashable type: 'set'
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is there a unique method in python to unique a list? Token Type <typetoken@gmail.com> - 2012-09-08 22:43 -0700
Re: Is there a unique method in python to unique a list? Chris Angelico <rosuav@gmail.com> - 2012-09-09 15:48 +1000
Re: Is there a unique method in python to unique a list? Chris Angelico <rosuav@gmail.com> - 2012-09-09 16:32 +1000
Re: Is there a unique method in python to unique a list? Token Type <typetoken@gmail.com> - 2012-09-08 23:44 -0700
Re: Is there a unique method in python to unique a list? Paul Rubin <no.email@nospam.invalid> - 2012-09-09 01:41 -0700
Re: Is there a unique method in python to unique a list? Paul Rubin <no.email@nospam.invalid> - 2012-09-09 02:06 -0700
Re: Is there a unique method in python to unique a list? Token Type <typetoken@gmail.com> - 2012-09-09 06:44 -0700
Re: Is there a unique method in python to unique a list? Chris Angelico <rosuav@gmail.com> - 2012-09-10 00:13 +1000
Re: Is there a unique method in python to unique a list? Serhiy Storchaka <storchaka@gmail.com> - 2012-09-09 11:36 +0300
csiph-web