POV-Ray : Newsgroups : povray.off-topic : Programming style question - specifically Python : Re: Programming style question - specifically Python Server Time
29 Jul 2024 14:17:17 EDT (-0400)
  Re: Programming style question - specifically Python  
From: Shay
Date: 21 Aug 2011 22:14:30
Message: <4e51bb86$1@news.povray.org>
On Sun, 21 Aug 2011 08:00:28 -0700, Darren New wrote:

> On 8/20/2011 22:52, Shay wrote:
>> On Fri, 19 Aug 2011 13:49:01 -0700, Darren New wrote:
>>
>>> On 8/19/2011 13:04, Shay wrote:
>>>> bool_a = len(A[0]) == 2
>>>> bool_b = min([A[2] == x[2] for x in A[1:]) bool_c = ccw_angle(*A)<  
>>>> pi
>>>>
>>>> bool_b will not work if bool_a is true
>>>
>>> bool_b = bool_a ? min(...) : false
>>
>> Beautiful, but that doesn't seem to be valid Python.
> 
> OK. I had assumed python had that operator. It's the same as
> 
> if bool_a then bool_b = min(...) else bool_b = false;
> 
>> bool_b = False if bool_a else min(...) does work. So, I learned
>> something there.
> 
> I think you *might* have the condition reversed on that. That looks like
> it's saying you don't evaluate bool_b if bool_a is true.

That's what I want. I mistyped a portion of my example

bool_b = min([A[2] == x[2] for x in A[1:])

should have been

bool_b = min([A[0][2] == x[2] for x in A[1:])

bool_b tests if all of the [2]s are equal. If bool_a is true, there are 
no [2]s.

Thanks for the help.

 -Shay


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.