Specifications

then you are going to see no output at all in Portal. Because the “signatures” do not match, Portal
does not invoke the displayStatus() function at all.
You can change the calling SNAPpy script(s), or you can change the Portal script, but they must
match.
Functions can return values
def adder(a, b):
return a + b
print adder(1, 2) # would print out "3"
Functions can do nothing
def placeHolder(a, b):
pass
Functions cannot be empty
def placeHolder(a, b):
# ERROR! - you have to at least put a "pass" statement here
Variables at the top of your script are global
x = 99 # this is a global variable
def sayHello():
print "x=", x
Variables within functions are usually local…
x = 99 # this is a global variable
def showNumber():
x = 123 # this is a separate local variable
print x # prints 123
…unless you explicitly say you mean the global one
x = 99 # this is a global variable
def showGlobal():
print x # this shows the current value of global variable x
def changeGlobal():
global x # because of this statement…
x = 99 # …this changes the global variable x
def changeLocal():
x = 42 # this statement does not change the global variable x
print x # will print 42 but the global variable x is unchanged
SNAP Reference Manual Document Number 600-0007K Page 19 of 202