Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108160
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Stephen Hansen <me+python@ixokai.io> |
| Newsgroups | comp.lang.python |
| Subject | Re: Whittle it on down |
| Date | Wed, 04 May 2016 22:39:15 -0700 |
| Lines | 47 |
| Message-ID | <mailman.397.1462426759.32212.python-list@python.org> (permalink) |
| References | <ngejmj$gc4$1@dont-email.me> <1462426755.15465.598690257.42990546@webmail.messagingengine.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de wGwWDIxHwI6T51idxI7O3AGKho1bKu3LzFY2QluX74/Q== |
| Return-Path | <me+python@ixokai.io> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'expressions': 0.07; 'received:internal': 0.09; 'fitness': 0.13; 'output': 0.13; 'wed,': 0.15; "'about": 0.16; '09:58': 0.16; 'courts': 0.16; 'dfs': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'input': 0.18; '>>>': 0.20; 'stephen': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; "skip:' 10": 0.28; 'regular': 0.29; 'job:': 0.29; 'skip:[ 10': 0.31; "skip:' 20": 0.34; 'list': 0.34; 'sometimes': 0.35; 'tool': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.40; 'header:Message-Id:1': 0.61; 'profile': 0.63; 'city': 0.65; 'clubs': 0.72; 'physical': 0.72; "'2',": 0.84; "'3',": 0.84; 'subject:down': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=qGxCjzptrZdtDZUEDCxLa3xd8eE=; b=MS7mq4 g1gAzK38Bb2V6mmggjkA9YrKtDTMB3jWOpZFNe0z/+/heroKL0wIiuVF5VpUBRpt Cb7I7TURkjO4Txpgi7JZOckGbINLq+8AaQtCNfSxCPsi6wXz1TnfPeZylHpZxq2K yuV1ZErLVdSwXuEvxzp95zMpsdGqa3VwhxEo4= |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=qGxCjzptrZdtDZU EDCxLa3xd8eE=; b=D2EB6qF8xrkzPHVK6NwYnMlHzBuCZexU9A82Fp42VK/mJeF D+8/k+xM0fiDdSLTvGlwXOdw3cHtT77z0oPH7LA0nPd1OJy51D/JbaQOK/U5etWI k5ej+pufjd5ui1D1EZeLVE1PwcPjakvDzHd0WF12o/4xSxHTfmbkzNRaqglE= |
| X-Sasl-Enc | E0l/F2+AbOwNnCJYShDoQV5Ei+G7kbtjiqv+7Td2av5z 1462426755 |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-9f40a94e |
| In-Reply-To | <ngejmj$gc4$1@dont-email.me> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <1462426755.15465.598690257.42990546@webmail.messagingengine.com> |
| X-Mailman-Original-References | <ngejmj$gc4$1@dont-email.me> |
| Xref | csiph.com comp.lang.python:108160 |
Show key headers only | View raw
On Wed, May 4, 2016, at 09:58 PM, DFS wrote: > Want to whittle a list like this: > > [u'Espa\xf1ol', 'Health & Fitness Clubs (36)', 'Health Clubs & > Gymnasiums (42)', 'Health Fitness Clubs', 'Name', 'Atlanta city guide', > 'edit address', 'Tweet', 'PHYSICAL FITNESS CONSULTANTS & TRAINERS', > 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', > 'www.custombuiltpt.com/', 'RACQUETBALL COURTS PRIVATE', > 'www.lafitness.com', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', > 'www.lafitness.com', 'HEALTH & FITNESS CLUBS', 'www.lafitness.com', > 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & > PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & > GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS', > '5', '4', '3', '2', '1', 'Yellow Pages', 'About Us', 'Contact Us', > 'Support', 'Terms of Use', 'Privacy Policy', 'Advertise With Us', > 'Add/Update Listing', 'Business Profile Login', 'F.A.Q.'] > > down to > > ['PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', > 'HEALTH CLUBS & GYMNASIUMS', 'RACQUETBALL COURTS PRIVATE', 'GYMNASIUMS', > 'HEALTH & FITNESS CLUBS', 'HEALTH & FITNESS CLUBS', 'PERSONAL FITNESS > TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS > PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS > & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS'] Sometimes regular expressions are the tool to do the job: Given: >>> input = [u'Espa\xf1ol', 'Health & Fitness Clubs (36)', 'Health Clubs & Gymnasiums (42)', 'Health Fitness Clubs', 'Name', 'Atlanta city guide', 'edit address', 'Tweet', 'PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'www.custombuiltpt.com/', 'RACQUETBALL COURTS PRIVATE', 'www.lafitness.com', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', 'www.lafitness.com', 'HEALTH & FITNESS CLUBS', 'www.lafitness.com', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS', '5', '4', '3', '2', '1', 'Yellow Pages', 'About Us', 'Contact Us', 'Support', 'Terms of Use', 'Privacy Policy', 'Advertise With Us', 'Add/Update Listing', 'Business Profile Login', 'F.A.Q.'] Then: >>> pattern = re.compile(r"^[A-Z\s&]+$") >>> output = [x for x in list if pattern.match(x)] >>> output ['PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'RACQUETBALL COURTS PRIVATE', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', 'HEALTH & FITNESS CLUBS', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS'] -- Stephen Hansen m e @ i x o k a i . i o
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 00:58 -0400
Re: Whittle it on down Stephen Hansen <me+python@ixokai.io> - 2016-05-04 22:39 -0700
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 08:44 -0400
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 19:31 -0400
Re: Whittle it on down Peter Otten <__peter__@web.de> - 2016-05-06 09:45 +0200
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-06 09:58 -0400
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-06 10:41 -0400
Re: Whittle it on down Peter Otten <__peter__@web.de> - 2016-05-06 17:44 +0200
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-06 18:43 -0400
Re: Whittle it on down alister <alister.ware@ntlworld.com> - 2016-05-06 10:01 +0000
Re: Whittle it on down Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-05 08:53 +0300
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 08:57 -0400
Re: Whittle it on down Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-05 16:04 +1000
Re: Whittle it on down Stephen Hansen <me+python@ixokai.io> - 2016-05-04 23:46 -0700
Re: Whittle it on down Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-05 17:04 +1000
Re: Whittle it on down Stephen Hansen <me+python@ixokai.io> - 2016-05-05 00:34 -0700
Re: Whittle it on down Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-05 18:41 +1000
Re: Whittle it on down Random832 <random832@fastmail.com> - 2016-05-05 09:13 -0400
Re: Whittle it on down Steven D'Aprano <steve@pearwood.info> - 2016-05-06 03:13 +1000
Re: Whittle it on down Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-05 17:36 +1000
Re: Whittle it on down Peter Otten <__peter__@web.de> - 2016-05-05 10:17 +0200
Re: Whittle it on down Steven D'Aprano <steve@pearwood.info> - 2016-05-06 01:39 +1000
Re: Whittle it on down Random832 <random832@fastmail.com> - 2016-05-05 09:21 -0400
Re: Whittle it on down Steven D'Aprano <steve@pearwood.info> - 2016-05-06 04:03 +1000
Re: Whittle it on down Random832 <random832@fastmail.com> - 2016-05-05 14:52 -0400
Re: Whittle it on down Stephen Hansen <me+python@ixokai.io> - 2016-05-05 12:09 -0700
Re: Whittle it on down Stephen Hansen <me+python@ixokai.io> - 2016-05-05 06:32 -0700
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 10:36 -0400
Re: Whittle it on down Steven D'Aprano <steve@pearwood.info> - 2016-05-06 03:43 +1000
Re: Whittle it on down Stephen Hansen <me+python@ixokai.io> - 2016-05-05 11:55 -0700
Re: Whittle it on down Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-05 20:49 +0300
Re: Whittle it on down Steven D'Aprano <steve@pearwood.info> - 2016-05-06 04:14 +1000
Re: Whittle it on down Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-05 21:27 +0300
Re: Whittle it on down Random832 <random832@fastmail.com> - 2016-05-05 14:54 -0400
Re: Whittle it on down Steven D'Aprano <steve@pearwood.info> - 2016-05-06 10:57 +1000
Re: Whittle it on down Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-06 07:19 +0300
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 08:31 -0400
Re: Whittle it on down Steven D'Aprano <steve@pearwood.info> - 2016-05-06 03:54 +1000
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 17:36 -0400
Re: Whittle it on down Stephen Hansen <me+python@ixokai.io> - 2016-05-05 11:56 -0700
Re: Whittle it on down DFS <nospam@dfs.com> - 2016-05-05 17:45 -0400
csiph-web