Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73050

Re: None in string => TypeError?

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!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <roy@panix.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; '"><span': 0.09; 'none)': 0.09; 'subject:None': 0.09; 'subject:string': 0.09; 'typed': 0.09; 'wrong,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'wrote': 0.14; 'language.': 0.14; 'none.': 0.16; 'received:166.84': 0.16; 'received:166.84.1': 0.16; 'received:166.84.1.89': 0.16; 'received:mailbackend.panix.com': 0.16; 'received:panix.com': 0.16; 'roy': 0.16; 'status)': 0.16; 'helvetica;': 0.16; ':-)': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'pfxlen:0': 0.19; 'received:10.0.1': 0.19; 'received:166': 0.19; 'cc:addr:python.org': 0.22; 'string,': 0.24; 'paul': 0.24; '---': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; '0);': 0.29; 'am,': 0.29; 'medium;': 0.30; "i'm": 0.30; 'code': 0.31; 'skip:- 30': 0.32; 'rgb(0,': 0.33; 'there,': 0.34; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'doing': 0.36; 'charset:us- ascii': 0.36; 'subject:?': 0.36; 'received:10.0': 0.36; 'skip:- 20': 0.37; 'received:10': 0.37; 'auto;': 0.38; 'skip:- 10': 0.38; 'little': 0.38; 'anything': 0.39; 'changed': 0.39; 'strictly': 0.61; "you're": 0.61; 'header:Message-Id:1': 0.63; 'to:addr:gmail.com': 0.65; 'smith': 0.68; '2014,': 0.84; 'email addr:panix.com': 0.84
Subject Re: None in string => TypeError?
Mime-Version 1.0 (Apple Message framework v1283)
Content-Type multipart/alternative; boundary="Apple-Mail=_4DF62E96-9084-4335-9554-A462B8C15FCF"
From Roy Smith <roy@panix.com>
In-Reply-To <20140609185728.3cac55ab@x34f>
Date Mon, 9 Jun 2014 12:53:59 -0400
References <048960da-c132-407f-b1b3-4612a3dd7697@googlegroups.com> <20140609185728.3cac55ab@x34f>
To Paul Sokolovsky <pmiscml@gmail.com>
X-Mailer Apple Mail (2.1283)
Cc python-list@python.org
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.10927.1402332848.18130.python-list@python.org> (permalink)
Lines 96
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1402332848 news.xs4all.nl 2838 [2001:888:2000:d::a6]:38704
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73050

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Jun 9, 2014, at 11:57 AM, Paul Sokolovsky wrote:

> This is very Pythonic, Python is strictly typed language. There's no
> way None could possibly be "inside" a string, so if you're trying to
> look for it there, you're doing something wrong, and told so.

Well, the code we've got is:

           hourly_data = [(t if status in 'CSRP' else None) for (t, status) in hours]

where status can be None.  I don't think I'm doing anything wrong.  I wrote exactly what I mean :-)  We've changed it to:

          hourly_data = [(t if (status and status in 'CSRP') else None) for (t, status) in hours]

but that's pretty ugly.  In retrospect, I suspect:

          hourly_data = [(t if status in set('CSRP') else None) for (t, status) in hours]

is a little cleaner.


---
Roy Smith
roy@panix.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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