Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'false,': 0.09; 'happen,': 0.09; 'literal': 0.09; 'none)': 0.09; 'repeated': 0.09; 'subject:None': 0.09; 'subject:string': 0.09; '10:59': 0.16; 'inclined': 0.16; 'iteration.': 0.16; 'roy': 0.16; 'status)': 0.16; 'syntax,': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'separate': 0.22; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'easier': 0.31; 'this.': 0.32; 'checking': 0.33; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'list': 0.37; 'clear': 0.37; 'to:addr:python-list': 0.38; 'little': 0.38; 'moving': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; "you're": 0.61; 'smith': 0.68; 'construction': 0.72; 'clearer': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=gYEyoVlhZJt0ZOgPheFVH9jHiWkyV7xf2K2eK7Hyeyw=; b=KyroPirC3kNoxbnZIkGDZTmwk4YZxS8w64pAHn77Vd7AJ/cY/WaQlawKCHOJmuZLNG /MrKbqzbPphQNfwjFSKlCr2McgvrcQkdrqvqfuAIG6Vm+7XQUdXcixy/G32UrtKBVeA5 vq+P/of2rtoEyz7QEhyKMNys4jM8UpsditY8HNgmvjuSF49og2bwSVWCQznPS9kQHO0Z 6J63deiOFQqvzhAwI1Znkkvg4pSApjsqQhVJslr2xWNFoESAbqIs1NRDC2q+7jMoFr4N zZ/yrdQExMIqgslgqCuKPNf3KpzeT9aDVtSVkLhCI58BnNeaqtU50Si5LCYUf6xJXPan 5Tww== X-Received: by 10.236.229.133 with SMTP id h5mr15776571yhq.64.1402334578396; Mon, 09 Jun 2014 10:22:58 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <048960da-c132-407f-b1b3-4612a3dd7697@googlegroups.com> <20140609185728.3cac55ab@x34f> <03B8D21C-62B4-4344-AA25-FF82501C33D0@panix.com> From: Ian Kelly Date: Mon, 9 Jun 2014 11:22:18 -0600 Subject: Re: None in string => TypeError? To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1402334970 news.xs4all.nl 2939 [2001:888:2000:d::a6]:47251 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73053 On Mon, Jun 9, 2014 at 10:59 AM, Chris Angelico wrote: > On Tue, Jun 10, 2014 at 2:53 AM, Roy Smith 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. Depending on how much work this has to do, I might also consider moving the set construction outside the list comprehension since it doesn't need to be repeated on every iteration.