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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
15 matches
Mail list logo