Re: List comprehension with if-else

2015-10-28 Thread Larry Martell
On Wed, Oct 28, 2015 at 12:36 PM, Zachary Ware wrote: > On Wed, Oct 28, 2015 at 11:25 AM, Larry Martell > wrote: >> I'm trying to do a list comprehension with an if and that requires an >> else, but in the else case I do not want anything added to the list. >> >> For example, if I do this: >> >>

Re: List comprehension with if-else

2015-10-28 Thread Carl Meyer
Hi Larry, On 10/28/2015 10:25 AM, Larry Martell wrote: > I'm trying to do a list comprehension with an if and that requires an > else, but in the else case I do not want anything added to the list. > > For example, if I do this: > > white_list = [l.control_hub.serial_number if l.wblist == > wbli

Re: List comprehension with if-else

2015-10-28 Thread Zachary Ware
On Wed, Oct 28, 2015 at 11:25 AM, Larry Martell wrote: > I'm trying to do a list comprehension with an if and that requires an > else, but in the else case I do not want anything added to the list. > > For example, if I do this: > > white_list = [l.control_hub.serial_number if l.wblist == wblist_e

List comprehension with if-else

2015-10-28 Thread Larry Martell
I'm trying to do a list comprehension with an if and that requires an else, but in the else case I do not want anything added to the list. For example, if I do this: white_list = [l.control_hub.serial_number if l.wblist == wblist_enum['WHITE'] else None for l in wblist] I end up with None in my