Re: create boolean

2009-03-09 Thread Andre Engels
On Mon, Mar 9, 2009 at 12:48 AM, Grant Edwards gra...@visi.com 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

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 n is always

Re: create boolean

2009-03-09 Thread Grant Edwards
On 2009-03-09, Andre Engels andreeng...@gmail.com wrote: On Mon, Mar 9, 2009 at 12:48 AM, Grant Edwards gra...@visi.com 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

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

Re: create boolean

2009-03-08 Thread Rhodri James
On Sat, 07 Mar 2009 05:03:08 -, Grant Edwards gra...@visi.com wrote: On 2009-03-07, Rhodri James rho...@wildebst.demon.co.uk wrote: On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards inva...@invalid wrote: On 2009-03-06, Fencer no.s...@plz.ok wrote: Hi, I need a boolean b to be true

Re: create boolean

2009-03-08 Thread Grant Edwards
On 2009-03-08, Rhodri James rho...@wildebst.demon.co.uk 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 less

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-07 Thread Paul Rubin
Fencer no.s...@plz.ok 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 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

Re: create boolean

2009-03-07 Thread Andre Engels
On Sat, Mar 7, 2009 at 6:03 AM, Grant Edwards gra...@visi.com 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

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

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 list

Re: create boolean

2009-03-06 Thread Grant Edwards
On 2009-03-06, Fencer no.s...@plz.ok 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

Re: create boolean

2009-03-06 Thread Rhodri James
On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards inva...@invalid wrote: On 2009-03-06, Fencer no.s...@plz.ok 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

Re: create boolean

2009-03-06 Thread Grant Edwards
On 2009-03-07, Rhodri James rho...@wildebst.demon.co.uk wrote: On Fri, 06 Mar 2009 15:34:08 -, Grant Edwards inva...@invalid wrote: On 2009-03-06, Fencer no.s...@plz.ok 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