Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33687
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '"""': 0.05; 'initialize': 0.05; 'lst': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:method': 0.09; 'def': 0.10; "wouldn't": 0.11; 'index': 0.13; '"list': 0.16; "'b'": 0.16; "'b',": 0.16; "'d',": 0.16; "['a',": 0.16; 'dest': 0.16; 'duplicates': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Problem': 0.16; 'then...': 0.16; 'later': 0.16; 'simpler': 0.22; 'elements': 0.23; 'list:': 0.27; 'header:X-Complaints-To:1': 0.28; '"the': 0.29; 'source': 0.29; 'print': 0.32; 'url:home': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'list': 0.35; 'nov': 0.35; 'list.': 0.35; 'add': 0.36; 'received:org': 0.36; 'subject:with': 0.36; 'charset:us-ascii': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'perform': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'remove': 0.61; 'skip:n 10': 0.63; '...and': 0.84; '10.0,': 0.84; '5.6': 0.84; 'alvaro': 0.84; 'combo': 0.84; 'dennis': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
| Subject | Re: Problem with list.remove() method |
| Date | Tue, 20 Nov 2012 19:08:20 -0500 |
| Organization | > Bestiaria Support Staff < |
| References | <b610616c-c26d-44e1-84c6-fa922a8e3f75@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | adsl-76-249-25-251.dsl.klmzmi.sbcglobal.net |
| X-Newsreader | Forte Agent 3.3/32.846 |
| X-No-Archive | YES |
| 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.120.1353456507.29569.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1353456507 news.xs4all.nl 6926 [2001:888:2000:d::a6]:47103 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33687 |
Show key headers only | View raw
On Tue, 20 Nov 2012 05:56:27 -0800 (PST), Alvaro Combo
<alvaro.combo@gmail.com> declaimed the following in
gmane.comp.python.general:
> ...And the code:
>
> def remove_dup_5_10():
> """
> Remove the duplicates of a given list. The original list MUST be kept.
> """
>
> # Set the original list
> lst = ['a', 1, 10.0, 2, 'd', 'b', 'b', 'b', 1, 2, 'b' ]
>
> # NEED to create a copy... See dicussion on Problem 5.6 and issue #2
> cpy_lst = list(lst)
>
Why copy the source list at the start and then...
> # Perform an infinite loop... explained later
> i=0 # initialize the index
> while i != len(cpy_lst):
> if cpy_lst.count(cpy_lst[i]) != 1:
> cpy_lst.remove(i)
... remove elements from the copy...
> else:
> i += 1
>
> print "The original List: ", lst
> print "List with NO duplicates: ", cpy_lst
>
Wouldn't it be simpler to just add each NON-duplicate of the source
to the destination?
dest = []
for itm in source:
if itm not in dest:
dest.append(itm)
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Problem with list.remove() method Alvaro Combo <alvaro.combo@gmail.com> - 2012-11-20 05:56 -0800
Re: Problem with list.remove() method Chris Angelico <rosuav@gmail.com> - 2012-11-21 01:14 +1100
Re: Problem with list.remove() method Alvaro Combo <alvaro.combo@gmail.com> - 2012-11-20 06:37 -0800
Re: Problem with list.remove() method Chris Angelico <rosuav@gmail.com> - 2012-11-21 07:48 +1100
Re: Problem with list.remove() method Alvaro Combo <alvaro.combo@gmail.com> - 2012-11-20 06:37 -0800
Re: Problem with list.remove() method Terry Reedy <tjreedy@udel.edu> - 2012-11-20 15:32 -0500
RE: Problem with list.remove() method "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-20 20:47 +0000
Re: Problem with list.remove() method Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-20 19:08 -0500
csiph-web