Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:localnet': 0.07; 'sqlite': 0.07; 'be:': 0.09; 'tuple': 0.09; '>>>': 0.12; 'am,': 0.14; 'wrote:': 0.14; '(1,': 0.16; '(2,': 0.16; 'element,': 0.16; 'pinner': 0.16; 'pythonic': 0.16; 'cc:2**0': 0.20; 'subject:list': 0.22; 'header:In-Reply-To:1': 0.22; 'loop': 0.22; 'query': 0.29; 'list': 0.30; 'cc:addr:gmail.com': 0.31; 'tuples': 0.31; 'wednesday': 0.31; 'to:addr:python-list': 0.32; 'header:User- Agent:1': 0.35; 'received:au': 0.36; 'apr': 0.38; 'url:org': 0.38; 'returning': 0.39; 'url:au': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'where': 0.39; 'solution': 0.40; 'would': 0.40; 'header:Message-Id:1': 0.62; '2011': 0.62; 'full': 0.62; '26,': 0.68; 'john,': 0.84 From: Algis Kabaila Organization: PCUG - Users Helping Users To: python-list@python.org Subject: Re: De-tupleizing a list Date: Thu, 28 Apr 2011 05:31:18 +1000 User-Agent: KMail/1.13.5 (Linux/2.6.35-25-generic-pae; KDE/4.5.1; i686; ; ) References: <8dcab23b-6e38-41d0-9591-ef3cbfdbd589@a21g2000prj.googlegroups.com> <9f0a8937-06ea-4e93-84ee-344a5b458f68@d28g2000yqf.googlegroups.com> In-Reply-To: <9f0a8937-06ea-4e93-84ee-344a5b458f68@d28g2000yqf.googlegroups.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: John Pinner 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: 33 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303932691 news.xs4all.nl 81482 [::ffff:82.94.164.166]:48882 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4154 On Wednesday 27 April 2011 20:56:20 John Pinner wrote: > On Apr 26, 4:28 am, Gnarlodious wrote: > > I have an SQLite query that returns a list of tuples: > > > > [('0A',), ('1B',), ('2C',), ('3D',),... > > > > What is the most Pythonic way to loop through the list > > returning a list like this?: > > > > ['0A', '1B', '2C', '3D',... > > > > -- Gnarlie > > If you want to handle a list of tuples where each tuple could > have > > *more* than one element, one solution would be: > >>> L = [(1, 2), (2, 3, 4), (5,), (6, 7, 8, 9, 0)] > >>> tuple([ x for t in L for x in t ]) > > (1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 0) > > > John > -- John, That really tickles me - full marks to you! OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf