[Tutor] Not workin!

Kent Johnson kent37 at tds.net
Wed Sep 30 13:44:34 CEST 2009


On Wed, Sep 30, 2009 at 1:32 AM, Luke Paireepinart
<rabidpoobear at gmail.com> wrote:
> Oops, thanks for catching that one Marty. I thought they both
> evaluated to false.

They both evaluate to false in a boolean context but that is different
from being *equal* to false or to each other.

In [1]: s = ''

In [2]: bool(s)
Out[2]: False

In [3]: s == False
Out[3]: False

In [4]: l = []

In [5]: bool(l)
Out[5]: False

In [6]: l == False
Out[6]: False

In [7]: s == l
Out[7]: False

Kent

>
> On 9/29/09, Martin Walsh <mwalsh at mwalsh.org> wrote:
>> Luke Paireepinart wrote:
>>> In this case you are saying "is their input equal to this list with many
>>> elements?" and the answer is always going to be No because a string
>>> won't be equal to a list unless both are empty.
>>
>> I know you probably didn't mean this as it reads, or as I'm reading it,
>> but an empty string and an empty list aren't 'equal' either.
>>
>> In [1]: '' == []
>> Out[1]: False
>>
>> HTH,
>> Marty


More information about the Tutor mailing list