POV-Ray : Newsgroups : povray.off-topic : Programming style question - specifically Python : Re: Programming style question - specifically Python Server Time
29 Jul 2024 14:18:56 EDT (-0400)
  Re: Programming style question - specifically Python  
From: Shay
Date: 19 Aug 2011 16:04:33
Message: <4e4ec1d1$1@news.povray.org>
On Wed, 17 Aug 2011 19:45:42 -0700, Darren New wrote:

> Hmm.
> 
>      y = (x for x in List)
>      if some_funk(y) or some_other_func(y) and a_third_func(y):
> 
> Why would you even want to calculate (x for x in List) three times?
> 
> Or am I misunderstanding "x for x in List"? Isn't that a list
> comprehension in Python?


That's just a BS example. Just a style question. Here's a real example of 
what I'm trying to do:

# A special case for 2-dimensional vectors
# with acute ccw angles
A = [[1, 2, 0], [2, 3, 4], [4, 8, 6]]

bool_a = len(A[0]) == 2
bool_b = min([A[2] == x[2] for x in A[1:])
bool_c = ccw_angle(*A) < pi

ccw_angle is my own function
bool_b will not work if bool_a is true

if bool_a or bool_b:
	if bool_c:

would mean code repetition where:
a or b is true and c is false
neither a nor b is true

So, maybe I do have the best answer with:
bool_ = long conditions
if bool_:


Post a reply to this message

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