Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73052
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '"if': 0.09; 'deemed': 0.09; 'false,': 0.09; 'happen,': 0.09; 'literal': 0.09; 'none)': 0.09; 'subject:None': 0.09; 'subject:string': 0.09; 'cc:addr :python-list': 0.11; "'0'": 0.16; '(it': 0.16; 'cryptic.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'roy': 0.16; 'set()': 0.16; 'status)': 0.16; 'syntax,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'work,': 0.20; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'string,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'easier': 0.31; 'this.': 0.32; 'quite': 0.32; 'checking': 0.33; "i'd": 0.34; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'clear': 0.37; 'little': 0.38; 'even': 0.60; "you're": 0.61; 'smith': 0.68; 'clearer': 0.84; 'to:none': 0.92 |
| 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=GyMdbM2SpOVvLJZNPn2rjOi7ad53rKZq1iC74dhQg9E=; b=y8pAvFTroQ8g7e8HrRHdlwkcw6tla1uGkMe6BdOQXyV1+F72dNk4Sxhj+TRWPXIuq3 SYpr7nwSOy9/y9xA6im0QATiI6k7Tci+6+HREA9EsgISvC9ikyiC7Plfc3REUVSh2AQo XOX0AemiSUxvGneT7uwFVfJ2bYHA/d4X/PBvgzHBZGK4tM9anVH2GIPbR708CBJhjnl+ tcqK0RxL83KDUR+jyBWe7cxk3bWN4iV/EULIWHmqukwFSH0x9Yd0Nl87v9rJhFz8fw4Q GjaPTXQGXjvFZnIPNui79Oesq/0rcT9hZof8g3rzhXEf9sfIoffcNF1i3QYSUWtjajzO s/Vg== |
| MIME-Version | 1.0 |
| X-Received | by 10.58.209.233 with SMTP id mp9mr28060373vec.30.1402333169950; Mon, 09 Jun 2014 09:59:29 -0700 (PDT) |
| In-Reply-To | <03B8D21C-62B4-4344-AA25-FF82501C33D0@panix.com> |
| References | <048960da-c132-407f-b1b3-4612a3dd7697@googlegroups.com> <20140609185728.3cac55ab@x34f> <03B8D21C-62B4-4344-AA25-FF82501C33D0@panix.com> |
| Date | Tue, 10 Jun 2014 02:59:29 +1000 |
| Subject | Re: None in string => TypeError? |
| 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.10929.1402333173.18130.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1402333173 news.xs4all.nl 2896 [2001:888:2000:d::a6]:43976 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73052 |
Show key headers only | View raw
On Tue, Jun 10, 2014 at 2:53 AM, Roy Smith <roy@panix.com> wrote:
> In retrospect, I suspect:
>
> hourly_data = [(t if status in set('CSRP') else None) for (t,
> status) in hours]
>
> is a little cleaner.
I'd go with this. It's clearer that a status of 'SR' should result in
False, not True. (Presumably that can never happen, but it's easier to
read.) I'd be inclined to use set literal syntax, even though it's a
bit longer - again to make it clear that these are four separate
strings that you're checking against.
Alternatively, you could go "if status or '0' in 'CSRP", which would
work, but be quite cryptic. (It would also mean that '' is not deemed
to be in the string, same as the set() transformation does.)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
None in string => TypeError? Roy Smith <roy@panix.com> - 2014-06-09 08:34 -0700
Re: None in string => TypeError? Ryan Hiebert <ryan@ryanhiebert.com> - 2014-06-09 10:42 -0500
Re: None in string => TypeError? Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-09 09:50 -0600
Re: None in string => TypeError? Paul Sokolovsky <pmiscml@gmail.com> - 2014-06-09 18:57 +0300
Re: None in string => TypeError? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-09 16:14 +0000
Re: None in string => TypeError? Chris Angelico <rosuav@gmail.com> - 2014-06-10 02:31 +1000
Re: None in string => TypeError? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-09 16:07 +0000
Re: None in string => TypeError? MRAB <python@mrabarnett.plus.com> - 2014-06-09 17:06 +0100
Re: None in string => TypeError? Shiyao Ma <i@introo.me> - 2014-06-10 00:13 +0800
Re: None in string => TypeError? Roy Smith <roy@panix.com> - 2014-06-09 12:53 -0400
Re: None in string => TypeError? Chris Angelico <rosuav@gmail.com> - 2014-06-10 02:59 +1000
Re: None in string => TypeError? Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-09 11:22 -0600
Re: None in string => TypeError? Chris Angelico <rosuav@gmail.com> - 2014-06-10 03:40 +1000
Re: None in string => TypeError? Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-09 11:58 -0600
Re: None in string => TypeError? Chris Angelico <rosuav@gmail.com> - 2014-06-10 04:02 +1000
csiph-web