Specifications

Creating globals on the fly
def newGlobal():
global x # this is a global variable, even without previous declaration
x = x + 1 # ERROR! - variables must be initialized before use
if x > 7: # ERROR! – variables must be initialized before use
pass
# Note that these two statements are NOT errors if some other function
# has previously initialized a value for global variable x before this
# function runs. Globals declared in this way have the same availability
# as globals explicitly initialized outside the scope of any function.
The usual conditionals are supported
Symbol Meaning
== Is equal to
!= Is not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
if 2 == 4:
print "something is wrong!"
if 1 != 1:
print "something is wrong!"
if 1 < 2:
print "that’s what I thought"
The usual math operators are supported
Symbol Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo (remainder function)
y = m*x + b
z = 5 % 4 # z is now 1
result = 8 / 4
SNAPpy does not support floating point, only integers.
SNAPpy integers are 16-bit signed values ranging from -32768 to 32767. If you add 1 to 32767, you
will get -32768.
SNAPpy does not generate an error if you divide by zero. The result of that division will be zero.
Page 20 of 202 SNAP Reference Manual Document Number 600-0007K