Tim Roberts wrote:
> Everything has a boolean value in
> Python. 0, None, False, '' (empty string), [] (empty list), () (empty
> tuple), and {} (empty dictionary) all have a False value. Everything else
> has a True value.
Empty set objects also evaluate as false in a boolean context.
Jeffrey
On 14 juil, 07:32, Tim Roberts <[EMAIL PROTECTED]> wrote:
(snip)
> Everything has a boolean value in
> Python. 0, None, False, '' (empty string), [] (empty list), () (empty
> tuple), and {} (empty dictionary) all have a False value. Everything else
> has a True value.
Unless the author of the cl
On Jul 14, 3:32 pm, Tim Roberts <[EMAIL PROTECTED]> wrote:
> maestro <[EMAIL PROTECTED]> wrote:
>
> >why does this work? "while p" = "while p != 0" ? 1 is True and 0 is
> >false in python but other numbers have no boolean value so why doesnt
> >it abort.
>
> Because your statement is incorrect. E
maestro <[EMAIL PROTECTED]> wrote:
>
>why does this work? "while p" = "while p != 0" ? 1 is True and 0 is
>false in python but other numbers have no boolean value so why doesnt
>it abort.
Because your statement is incorrect. Everything has a boolean value in
Python. 0, None, False, '' (empty st
maestro wrote:
why does this work? "while p" = "while p != 0" ? 1 is True and 0 is
false in python but other numbers have no boolean value so why doesnt
it abort.
p=16
p
16
while p:
print p
p -= 1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
i can also do:
k=[]
while k:
why does this work? "while p" = "while p != 0" ? 1 is True and 0 is
false in python but other numbers have no boolean value so why doesnt
it abort.
>>> p=16
>>> p
16
>>> while p:
print p
p -= 1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
>>>
i can also do:
>>> k=[]
>>> while k: