None in string => TypeError?
Chris Angelico
rosuav at gmail.com
Mon Jun 9 12:59:29 EDT 2014
More information about the Python-list mailing list
Mon Jun 9 12:59:29 EDT 2014
- Previous message (by thread): None in string => TypeError?
- Next message (by thread): None in string => TypeError?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jun 10, 2014 at 2:53 AM, Roy Smith <roy at 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
- Previous message (by thread): None in string => TypeError?
- Next message (by thread): None in string => TypeError?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list