Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4154
| 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 | <akabaila@pcug.org.au> |
| 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 <akabaila@pcug.org.au> |
| 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 <funthyme@gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.904.1303932691.9059.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
On Wednesday 27 April 2011 20:56:20 John Pinner wrote:
> 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
> --
John,
That really tickles me - full marks to you!
OldAl.
--
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
Back to comp.lang.python | Previous | Next — Previous 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