Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; '(new)': 0.09; '>>>>': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'wrote:': 0.14; 'iterable,': 0.16; 'mylist': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'subject:Converting': 0.16; 'subject:set': 0.16; 'converting': 0.16; 'object,': 0.19; 'subject:list': 0.22; 'worked': 0.24; 'skip:[ 10': 0.26; 'list': 0.30; 'from:addr:web.de': 0.31; 'to:addr:python-list': 0.32; 'another': 0.32; "i've": 0.33; 'creates': 0.33; 'header:X-Complaints-To:1': 0.34; 'actually': 0.34; 'there': 0.35; 'list.': 0.35; 'too': 0.36; 'received:org': 0.38; 'set': 0.39; 'to:addr:python.org': 0.39; 'header:Mime- Version:1': 0.39; 'solution': 0.40; 'would': 0.40; 'header:Received:5': 0.40; 'here.': 0.68 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Converting a set into list Date: Sat, 14 May 2011 11:33:15 +0200 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084a247.dip.t-dialin.net X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305365545 news.xs4all.nl 41110 [::ffff:82.94.164.166]:40720 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5358 TheSaint wrote: > I've stumble to find a solution to get a list from a set > > > >>>> aa= ['a','b','c','f'] >>>> aa > ['a', 'b', 'c', 'f'] >>>> set(aa) To clarify: this creates a new object, so aa is still a list. > {'a', 'c', 'b', 'f'} >>>> [k for k in aa] > ['a', 'b', 'c', 'f'] So you are actually converting a list to a (new) list here. Of course it would have worked with a set or an arbitrary iterable, too. > > I repute the comprehension list too expensive, is there another method? mylist = list(myset) Do you notice the similarity to converting a list to a set?