Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61387
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.139 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.78; '*S*': 0.06; 'inspired': 0.05; 'ugly': 0.07; 'operator,': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'looks': 0.24; 'cc:2**0': 0.24; 'skip:" 20': 0.27; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'comment': 0.34; 'received:google.com': 0.35; 'really': 0.36; 'doing': 0.36; 'filter': 0.38; 'break': 0.61; 'name': 0.63; 'kind': 0.63; 'skip:n 10': 0.64; 'choose': 0.64; 'finally': 0.65; 'customers': 0.66; 'subject:One': 0.74; 'special': 0.74; 'to:none': 0.92; 'insane': 0.93; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=+YioPbo5E2xv43KeqXl/sLNu596d7SNdZCZYM+kV9po=; b=LmRB+5uAwWBTf08Ur//nz+qS00XDnnk1DuSTdVi5aM6evJ6nxwuXOQF5RLkDSfibSv kMfyrNUVRSzkwaQ2GwQ521qAF/hc8owHI3tccPnQisCJwq+d9AQy3h294kEGF3QVgSb4 FfDg1G+4iPPVuBUJAmdLYIdzZQwaJZ9TBdQGtEcOqnJt4IbkgWX3qG+CqzA0uzRxlNc/ g0SIlCTmvMZCDMps6bnSshpptJUyByvkBp8hZZ2S7DMs4jME4D1avoGoytj2gOLuWT8q ac7F0zxPGes60SV2SyF1sDvaH21c1Di2uRkRUMZ+dCPSFcdJ0wruhyzaBIq61WLtWUFI fVwQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.164.136 with SMTP id yq8mr21316157pab.67.1386597563494; Mon, 09 Dec 2013 05:59:23 -0800 (PST) |
| In-Reply-To | <l84hp4$nh$1@ger.gmane.org> |
| References | <mailman.3674.1386374070.18130.python-list@python.org> <52a282d1$0$30003$c3e8da3$5496439d@news.astraweb.com> <CAGGBd_q3rQSY=5p0DjqTC5327Kap-hDvVA8V1V_D12avp-fM3A@mail.gmail.com> <l84hp4$nh$1@ger.gmane.org> |
| Date | Tue, 10 Dec 2013 00:59:23 +1100 |
| Subject | Re: One liners |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3779.1386597567.18130.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386597567 news.xs4all.nl 2938 [2001:888:2000:d::a6]:37823 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61387 |
Show key headers only | View raw
On Tue, Dec 10, 2013 at 12:49 AM, Neil Cerutti <neilc@norwich.edu> wrote:
> names = (p.name for p in db.query_people() if p.total_purchases > 0)
> names = (n.upper() for n in names)
> names = (n for n in names if not n.startswith("Q"))
> for n in names:
> # Finally actually do something.
>
> Coincidentally it's a nice way to break up an ugly one-liner. I
> also really like that if I choose to no longer filter out
> customers whose name begins with Q, I can just comment out that
> one line. Try doing that with the one-liner version!
# With the restriction:
for n in (p.name.upper() for n in names if not n.startswith("Q")):
# Without the restriction:
for n in (p.name.upper() for n in names ):# if not n.startswith("Q")):
You just have to use the special "comment-out-partially" operator,
which looks like "):#" and is inspired by some kind of insane smiley
with weird hair.
ChrisA
(Anyone got the cheek de-tonguer handy?)
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
One liners Dan Stromberg <drsalists@gmail.com> - 2013-12-06 15:54 -0800
Re: One liners Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-07 02:07 +0000
Re: One liners Dan Stromberg <drsalists@gmail.com> - 2013-12-06 19:20 -0800
Re: One liners Roy Smith <roy@panix.com> - 2013-12-06 22:53 -0500
Re: One liners Steven D'Aprano <steve@pearwood.info> - 2013-12-10 03:36 +0000
Re: One liners Neil Cerutti <neilc@norwich.edu> - 2013-12-09 13:49 +0000
Re: One liners Chris Angelico <rosuav@gmail.com> - 2013-12-10 00:59 +1100
csiph-web