Quote:
Originally Posted by donat2
Thanks a lot Michael
I see that in your code you create two lists variables with list comprehension: selReads and allReads.
The allReads variable is created inside the first for loop. Is that mandatory ? Or could you define those two lists first, then proceed to the loop inside the loop ?
(Sorry if this is off-topic, I realize it's purely a Python problem unrelated to Nuke. I googled things like "nested loop scope python" but didn't find an answer)
Regards
|
Hey no problem ... vfx is as much about python these days as python is about vfx.
Nope, it's totally not mandatory ... in fact the only reason it's there is cause I was originally doing a variant where I was going to not change the color of the selected read, just the duplicates ... and well it all gets a bit complicated, but I really just wanted to answer the question in the shortest amount of time.
Actually to be most efficient in this case, allReads should be initialized immediately after the if len(selRead) != 0 statement. That way if selRead fails (there are no reads to check) you never bother wasting processor cycles on allReads, but it avoids the multiple duplications I've accidentally forced it to do in this case. List comps are very fast, but it's still not worth duping the work ... if I'd kept going down my original path I'd have needed to, but with the code I ended up with it's redundant.
Good catch.
Michael