I saw some example python code:
for neighbor in active[i-(i>0):i+1]:
and just curious what i-(i>0)
here do?
I saw some example python code:
for neighbor in active[i-(i>0):i+1]:
and just curious what i-(i>0)
here do?
(i>0)
is a condition that is True
when i>0
and thus yields 1.
You can think of it also as active[i-{1 if i > 0, else 0}:i+1]:
A good comment by @Mad Physicist: bools are a subclass of int where {True,False} == {1,0}. You can find more on this here
Quote from the link above about this code:
No one would recommend using a boolean result in a numeric context