Gh python save only previous variable and compare

Hi all,

I’m still very new to python and was wondering if there’s a quick way to be able to check whether the latest variable is greater or smaller than the previous input.

I am trying to animate increasing or decreasing arrows in gh as part of a visualisation which I was assuming could be done by using python to input true or false.

Hello,

How about this:
EDIT : This is what you asked for
image

if 'previous' not in locals():
    previous = float('-inf')

if x > previous:
    a = True
else:
    a = False

previous = x

EDIT : not this !

image

if 'maximum' not in locals():
    maximum = float('-inf')

if x > maximum:
    maximum = x

a = maximum

I’m not by the computer so I can’t type any code.
But you can solve this by using sticky: https://developer.rhino3d.com/guides/rhinopython/ghpython-global-sticky/