Specifications

3. SNAPpy – The Language
SNAPpy is basically a subset of Python, with a few extensions to better support embedded real-time
programming. Here is a quick overview of the SNAPpy language.
Statements must end in a newline
print "I am a statement"
The # character marks the beginning of a comment
print "I am a statement with a comment" # this is a comment
Indentation is significant
The amount of indentation is up to you (4 spaces is standard for Python) but be consistent.
print "I am a statement"
print "I am a statement at a different indentation level" # this is an error
Indentation is used after statements that end with a colon (:)
if x == 1:
print "Found number 1"
Branching is supported via “if”/“elif”/“else”
if x == 1:
print "Found number 1"
elif x == 2:
print "Found number 2"
else:
print "Did not find 1 or 2"
Looping is supported via “while”
x = 10
while x > 0:
print x
x = x - 1
Identifiers are case sensitive
X = 1
x = 2
Here “X” and “x” are two different variables
Identifiers must start with a non-numeric character
x123 = 99 # OK
123x = 99 # not OK
SNAP Reference Manual Document Number 600-0007K Page 17 of 202