Re: create boolean

2009-03-09 Thread Grant Edwards
On 2009-03-09, Andre Engels wrote: > On Mon, Mar 9, 2009 at 12:48 AM, Grant Edwards wrote: > >> I didn't say that he hadn't authorized that assumption. ??I >> just said that the code does rely on such an assumption. ??In >> my experience, assumptions like that result broken code down >> the road.

Re: create boolean

2009-03-09 Thread Steve Holden
Lie Ryan wrote: > Fencer wrote: >> Hi, I need a boolean b to be true if the variable n is not None and >> not an empty list, otherwise b should be false. >> I ended up with: >> b = n is not None and not not n >> which seems to work but is that normally how you would do it? >> It can be assumed that

Re: create boolean

2009-03-09 Thread Andre Engels
On Mon, Mar 9, 2009 at 12:48 AM, Grant Edwards wrote: > I didn't say that he hadn't authorized that assumption.  I just > said that the code does rely on such an assumption.  In my > experience, assumptions like that result broken code down the > road. And assumptions like "when assumptions fail

Re: create boolean

2009-03-08 Thread Grant Edwards
On 2009-03-08, Rhodri James wrote: b = (n is not None) and (n != []) >>> >>> The second comparison isn't actually necessary, since an >>> empty list is True and a non-empty one False. >>> >>>b = (n is not None) and n >>> >>> Putting the comparison in does make the code slightly les

Re: create boolean

2009-03-08 Thread Rhodri James
On Sat, 07 Mar 2009 05:03:08 -, Grant Edwards wrote: On 2009-03-07, Rhodri James wrote: On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards wrote: On 2009-03-06, Fencer wrote: Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should b

Re: create boolean

2009-03-08 Thread Lie Ryan
Scott David Daniels wrote: Lie Ryan wrote: Fencer wrote: The literal translation of that would be: if n is not None and n != []: b = True else: b = False it is a bit verbose, so one might want to find something shorter b = True if n is not None and n != [] else False I always feel if and

Re: create boolean

2009-03-07 Thread Andre Engels
On Sat, Mar 7, 2009 at 6:03 AM, Grant Edwards wrote: > Putting in the second comparison in makes the code match the > stated requirement.  Otherwise you have to start making > assumptions about what n might be besides None or the empty > list. But the stated requirement already assumes that n is

Re: create boolean

2009-03-07 Thread Scott David Daniels
Lie Ryan wrote: Fencer wrote: The literal translation of that would be: if n is not None and n != []: b = True else: b = False it is a bit verbose, so one might want to find something shorter b = True if n is not None and n != [] else False I always feel if and in-line if to be easier and

Re: create boolean

2009-03-07 Thread Paul Rubin
Fencer writes: > Hi, I need a boolean b to be true if the variable n is not None and > not an empty list, otherwise b should be false > It can be assumed that n is always None or a list that might be empty b = bool(n) -- http://mail.python.org/mailman/listinfo/python-list

Re: create boolean

2009-03-07 Thread Lie Ryan
Fencer wrote: Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should be false. I ended up with: b = n is not None and not not n which seems to work but is that normally how you would do it? It can be assumed that n is always None or a list that

Re: create boolean

2009-03-06 Thread Grant Edwards
On 2009-03-07, Rhodri James wrote: > On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards wrote: > >> On 2009-03-06, Fencer wrote: >> >>> Hi, I need a boolean b to be true if the variable n is not >>> None and not an empty list, otherwise b should be false. >> >>> I ended up with: >> >>> b = n is n

Re: create boolean

2009-03-06 Thread Rhodri James
On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards wrote: On 2009-03-06, Fencer wrote: Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should be false. I ended up with: b = n is not None and not not n I'd do it like this: b = (n is

Re: create boolean

2009-03-06 Thread Grant Edwards
On 2009-03-06, Fencer wrote: > Hi, I need a boolean b to be true if the variable n is not > None and not an empty list, otherwise b should be false. > I ended up with: > b = n is not None and not not n I'd do it like this: b = (n is not None) and (n != []) Your code doesn't meet your state

Re: create boolean

2009-03-06 Thread Christian Heimes
Fencer schrieb: > Hi, I need a boolean b to be true if the variable n is not None and not > an empty list, otherwise b should be false. > I ended up with: > b = n is not None and not not n > which seems to work but is that normally how you would do it? > It can be assumed that n is always None or a

create boolean

2009-03-06 Thread Fencer
Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should be false. I ended up with: b = n is not None and not not n which seems to work but is that normally how you would do it? It can be assumed that n is always None or a list that might be empty