POV-Ray : Newsgroups : povray.off-topic : Programming style question - specifically Python : Re: Programming style question - specifically Python Server Time
29 Jul 2024 14:16:48 EDT (-0400)
  Re: Programming style question - specifically Python  
From: Kevin Wampler
Date: 18 Aug 2011 12:02:50
Message: <4e4d37aa$1@news.povray.org>
On 8/17/2011 7:45 PM, 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?
>

It's not a list comprehension, but rather creates a generator object 
iterating over the items in List.  The list comprehension would use 
square brackets [x for x in List].  I still don't understand why it's 
being used here though, since it seems like List could just be passed in 
directly since it's obviously iterable too (unless the called functions 
are doing something odd, which maybe is the case here).


Post a reply to this message

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