At 12:51 AM 7/14/2008, Alan Gauld wrote:
"Dick Moores" <[EMAIL PROTECTED]> wrote
5.10 Boolean operations
"In the context of Boolean operations, and also when expressions
are used by control flow statements, the following values are
interpreted as false: |False|, |None|, numeric zero of a
"Dick Moores" <[EMAIL PROTECTED]> wrote
5.10 Boolean operations
"In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are
interpreted as false: |False|, |None|, numeric zero of all types,
and empty strings and container
At 03:57 PM 7/13/2008, bob gailer wrote:
When all else fails RTFM:
5.10 Boolean operations
"In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are
interpreted as false: |False|, |None|, numeric zero of all types,
and
When all else fails RTFM:
5.10 Boolean operations
"In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are interpreted as
false: |False|, |None|, numeric zero of all types, and empty strings and
containers (including st
On Sun, Jul 13, 2008 at 1:06 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> In other words, "(3,2)" isn't exactly the same as "True" - but it doesn't
> evaluate to False, either, so it's true.
>
>
> So what does (3,2) evaluate to? Or is that a meaningless question? However
> in the following exampl
At 08:46 PM 7/12/2008, Marc Tompkins wrote:
On Sat, Jul 12, 2008 at 8:10 PM,
Dick Moores <[EMAIL PROTECTED]>
wrote:
But why will a tuple with two elements will always evaluate to
True?
In [2]: (3,5) == True
Out[2]: False
In [3]: ("qwerty", "asdfg") == True
Out[3]: False
In [4]:
The valu
At 12:40 PM 7/13/2008, Martin Walsh wrote:
Dick Moores wrote:
> At 11:44 AM 7/13/2008, Steve Willoughby wrote:
>> Dick Moores wrote:
>>> Yes! A rule, not logic. I'm not contradicting Kent, just helping
>>> myself understand. First the rule, then logic in the application of
>>> the rule. And I ass
Hi Dick,
because set(list) creates an unsorted collection without duplicate entrys
of the items in the list.
If you pass an empty list, the resulting set will also be an empty
collection.
A list containing an empty list evaluates non false, since it's not empty.
Maybe it helps you to compar
Dick Moores wrote:
> At 11:44 AM 7/13/2008, Steve Willoughby wrote:
>> Dick Moores wrote:
>>> Yes! A rule, not logic. I'm not contradicting Kent, just helping
>>> myself understand. First the rule, then logic in the application of
>>> the rule. And I assume the rule is there in Python because it ma
At 11:44 AM 7/13/2008, Steve Willoughby wrote:
Dick Moores wrote:
Yes! A rule, not logic. I'm not
contradicting Kent, just helping myself understand. First the rule, then
logic in the application of the rule. And I assume the rule is there in
Python because it makes things work better.
Yes, so a
Dick Moores wrote:
Yes! A rule, not logic. I'm not contradicting Kent, just helping myself
understand. First the rule, then logic in the application of the rule.
And I assume the rule is there in Python because it makes things work
better.
Yes, so a statement like "if foo:" becomes an idiom f
At 12:50 AM 7/13/2008, Alan Gauld wrote:
"Dick Moores"
<[EMAIL PROTECTED]> wrote
But why will a tuple with two
elements will always evaluate to
True?
Thats the rule for evaluationg collections in Python.
An empty collection is False. Anything else is therefore
true
Yes! A rule, not logic. I'm no
"Dick Moores" <[EMAIL PROTECTED]> wrote
But why will a tuple with two elements will always evaluate to
True?
Thats the rule for evaluationg collections in Python.
An empty collection is False. Anything else is therefore true
if []: -> false
if [1,2]: -> true
if (): -> false
if (1,2) - True
Dick Moores wrote:
> At 07:39 PM 7/12/2008, Kent Johnson wrote:
>> On Sat, Jul 12, 2008 at 6:03 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
>> > At 01:34 PM 7/12/2008, Kent Johnson wrote:
>>
>> >> In [2]: assert(False, "Asserted false")
>> >>
>> >> This is "assert condition" where the condition is a
On Sat, Jul 12, 2008 at 8:10 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> But why will a tuple with two elements will always evaluate to
> True?
>
> In [2]: (3,5) == True
> Out[2]: False
> In [3]: ("qwerty", "asdfg") == True
> Out[3]: False
> In [4]:
>
>
The value formally known as True is only on
At 07:39 PM 7/12/2008, Kent Johnson wrote:
On Sat, Jul 12, 2008 at 6:03 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> At 01:34 PM 7/12/2008, Kent Johnson wrote:
>> In [2]: assert(False, "Asserted false")
>>
>> This is "assert condition" where the condition is a tuple with two
>> elements, hence t
On Sat, Jul 12, 2008 at 6:03 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> At 01:34 PM 7/12/2008, Kent Johnson wrote:
>> In [2]: assert(False, "Asserted false")
>>
>> This is "assert condition" where the condition is a tuple with two
>> elements, hence true so there is no output.
>
> In [13]: asser
At 01:34 PM 7/12/2008, Kent Johnson wrote:
On Sat, Jul 12, 2008 at 4:01 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> _Python in a NutShell_, p. 138 has a bit on the assert statement which I
> don't completely understand.
>
> It says the syntax is
>
> assert condition[, expression]
>
> I was hopin
At 01:24 PM 7/12/2008, Danny Yoo wrote:
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
> In my code I have
>
> assert(len(list(set(colors_used_this_cycle))) ==
> len(colors_used_this_cycle), "A color has been used twice!")
>
> But it doesn't work. Cases where a color has been used m
At 01:28 PM 7/12/2008, Michiel Overtoom wrote:
Dick wrote:
> I was hoping to put some sort of explanation of failure in an
> assert statement. But how to do it?
> So I'd like to know what that 'expression' in the syntax can be,
> and how to use it.
I think it would help if you separate the dete
On Sat, Jul 12, 2008 at 4:01 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> _Python in a NutShell_, p. 138 has a bit on the assert statement which I
> don't completely understand.
>
> It says the syntax is
>
> assert condition[, expression]
>
> I was hoping to put some sort of explanation of failure
Dick wrote:
> I was hoping to put some sort of explanation of failure in an
> assert statement. But how to do it?
> So I'd like to know what that 'expression' in the syntax can be,
> and how to use it.
I think it would help if you separate the detection of duplicate colors from
the assert state
> In my code I have
>
> assert(len(list(set(colors_used_this_cycle))) ==
> len(colors_used_this_cycle), "A color has been used twice!")
>
> But it doesn't work. Cases where a color has been used more than once go
> right through it
Let's try a simple example.
Go back to the structure of an asse
_Python in a NutShell_, p. 138 has a bit on the assert statement which I
don't completely understand.
It says the syntax is
assert condition[, _expression_]
I was hoping to put some sort of explanation of failure in an assert
statement. But how to do it?
In my code I have
assert(len(list(set(colo
24 matches
Mail list logo