True of False

Erik Jones erik at myemma.com
Thu Sep 27 19:29:08 CEST 2007


On Sep 27, 2007, at 11:47 AM, Marc 'BlackJack' Rintsch wrote:

> On Thu, 27 Sep 2007 09:33:34 -0700, koutoo wrote:
>
>> I tried writing a true and false If statement and didn't get
>> anything?  I read some previous posts, but I must be missing
>> something.  I just tried something easy:
>>
>> a = ["a", "b", "c", "d", "e", "f"]
>>
>> if "c" in a == True:
>>      Print "Yes"
>>
>> When I run this, it runs, but nothing prints.  What am I doing wrong?
>
> Wow that's odd:
>
> In [265]: a = list('abcdef')
>
> In [266]: a
> Out[266]: ['a', 'b', 'c', 'd', 'e', 'f']
>
> In [267]: 'c' in a
> Out[267]: True
>
> In [268]: 'c' in a == True
> Out[268]: False
>
> In [269]: ('c' in a) == True
> Out[269]: True
>
> In [270]: 'c' in (a == True)
> ---------------------------------------------------------------------- 
> -----
> <type 'exceptions.TypeError'>             Traceback (most recent  
> call last)
>
> /home/bj/<ipython console> in <module>()
>
> <type 'exceptions.TypeError'>: argument of type 'bool' is not iterable
>
>
> What's going on there?

That is weird.  Given 270, what's happening in 268.

Erik Jones

Software Developer | Emma®
erik at myemma.com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com





More information about the Python-list mailing list