1-(2*variable_value)
would give you those values ... but there is a strong chance this is not what you want ... because its really hard to tell what you want
since you have clarified that you want speed for shaders I figured I would add this info
In [3]: %timeit x= 1 if not random.randint(0,1) else -1 #if statement
1000000 loops, best of 3: 1.31 us per loop
In [4]: %timeit x= 1-(2*random.randint(0,1)) #simple math
1000000 loops, best of 3: 1.32 us per loop
In [5]: %timeit x= [1,-1][random.randint(0,1)] #array lookup
1000000 loops, best of 3: 1.41 us per loop
In [7]: %timeit x= arr[random.randint(0,1)]
1000000 loops, best of 3: 1.31 us per loop
I actually was a little surprised that the array lookup was slower (Actually only if you dont already have the array constructed)