Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4125
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!d28g2000yqf.googlegroups.com!not-for-mail |
|---|---|
| From | John Pinner <funthyme@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: De-tupleizing a list |
| Date | Wed, 27 Apr 2011 03:56:20 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 23 |
| Message-ID | <9f0a8937-06ea-4e93-84ee-344a5b458f68@d28g2000yqf.googlegroups.com> (permalink) |
| References | <8dcab23b-6e38-41d0-9591-ef3cbfdbd589@a21g2000prj.googlegroups.com> |
| NNTP-Posting-Host | 217.169.24.93 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | posting.google.com 1303901780 14633 127.0.0.1 (27 Apr 2011 10:56:20 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Wed, 27 Apr 2011 10:56:20 +0000 (UTC) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | d28g2000yqf.googlegroups.com; posting-host=217.169.24.93; posting-account=APt1LgoAAAD5No0nL6rcc6kAzoEzsjqa |
| User-Agent | G2/1.0 |
| X-HTTP-Via | 1.1 ipcop.clocksoft.dom:800 (squid/2.6.STABLE21) |
| X-HTTP-UserAgent | Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16,gzip(gfe) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4125 |
Show key headers only | View raw
On Apr 26, 4:28 am, Gnarlodious <gnarlodi...@gmail.com> 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
--
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
De-tupleizing a list Gnarlodious <gnarlodious@gmail.com> - 2011-04-25 20:28 -0700
Re: De-tupleizing a list CM <cmpython@gmail.com> - 2011-04-25 20:42 -0700
Re: De-tupleizing a list Gnarlodious <gnarlodious@gmail.com> - 2011-04-25 20:52 -0700
Re: De-tupleizing a list "Littlefield, Tyler" <tyler@tysdomain.com> - 2011-04-25 21:38 -0600
Re: De-tupleizing a list Philip Semanchuk <philip@semanchuk.com> - 2011-04-25 23:38 -0400
Re: De-tupleizing a list Paul Rubin <no.email@nospam.invalid> - 2011-04-25 21:08 -0700
Re: De-tupleizing a list John Connor <john.theman.connor@gmail.com> - 2011-04-25 23:29 -0500
Re: De-tupleizing a list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-26 04:59 +0000
Re: De-tupleizing a list rusi <rustompmody@gmail.com> - 2011-04-25 22:26 -0700
Re: De-tupleizing a list Gnarlodious <gnarlodious@gmail.com> - 2011-04-26 05:19 -0700
Re: De-tupleizing a list Algis Kabaila <akabaila@pcug.org.au> - 2011-04-27 04:30 +1000
Re: De-tupleizing a list Hans Georg Schaathun <hg@schaathun.net> - 2011-04-26 21:11 +0100
Re: De-tupleizing a list Ethan Furman <ethan@stoneleaf.us> - 2011-04-26 13:37 -0700
Re: De-tupleizing a list Hans Georg Schaathun <hg@schaathun.net> - 2011-04-26 21:58 +0100
Re: De-tupleizing a list Raymond Hettinger <python@rcn.com> - 2011-04-26 14:16 -0700
Re: De-tupleizing a list John Pinner <funthyme@gmail.com> - 2011-04-27 03:56 -0700
Re: De-tupleizing a list Algis Kabaila <akabaila@pcug.org.au> - 2011-04-28 05:31 +1000
csiph-web