User manual
Variables do have types, but they can change on the fly
x = 99 # variable x is currently an integer (int)
x = False # variable x is now a Boolean value of False
x = "hello" # variable x is now a string (str)
x = (x == "hello") # variable x is now a Boolean value of True
Funcons can change, too
If you have two funcon definions that define funcons with the same name, even with different parameter
signatures, only the second funcon will be available. You cannot overload funcon names in SNAPpy based on
the number or type of parameters expected.
You can use a special type of comment called a “docstring”
At the top of a script, and aer the beginning of any funcon definion, you can put a specially formaed string
to provide inline documentaon about that script or funcon. These special strings are called “docstrings.”
“Docstrings” should be delimited with three single quote characters (') or three double quote (") characters.
(Use double quotes if your string will span more than one line.) Here are some examples:
"""
This could be the docstring at the top of a source file, explaining
what the purpose of the file is
"""
def printHello():
"""this function prints a short greeting"""
print "hello"
These “docstrings” will appear as tool-ps in some porons of the Portal GUI. They are also considered a good
pracce in Python programming.
12 SNAP® Network Operang System