User manual
4. SNAPpy versus Python
Here are more details about SNAPpy, with emphasis on the differences between SNAPpy and Python.
Modules
SNAPpy supports import of user-defined as well as standard predefined Python source library modules.
from module import * # Supported
from module import myFunction # Supported
import module # Not supported
Variables
Local and Global variables are supported. On RAM-constrained devices, SNAPpy images are typically limited to
64 system globals and 64 concurrent locals. Per-plaorm values are given in the SNAP Reference Manual.
Funcons
Up to 255 “public” funcons may be defined. These are remotely callable using the SNAP RPC protocol, and
include the SNAPpy built-in funcons.
Non-public funcons (prefixed with underscore) are limited only by the size of FLASH memory. These are not
remotely callable, but can be called by other funcons in the same script. (That is what it means to be non-
public.)
Any non-public funcons contained in an imported module will not be included when using
from module
import *
, but you can explicitly import non-public funcons using from module import _myFunction.
It is not recommended that you use non-public funcons for hooked events, as scripts with a large number of
constants and/or funcons (public and non-public) can cause the hooks to invoke the wrong script at run-me.
Data Types
SNAPpy supports the following fundamental Python data types:
• NoneType – None is a valid value
• int – An int in SNAPpy is a signed 16-bit integer, -32768 through 32767. 32767 + 1 = -32768.
• bool – A bool has a value of either True or False. (Note that those are case-sensive.)
• string – A stac string has a maximum size of 255 bytes. If you assign a literal to a string when the string
is created, either inside a funcon or as a global, this is the size limit that will be applied. However if you
assign a value to a string while a script is running, or aempt to reassign a value to a string declared
outside a funcon, SNAPpy uses a different collecon of string buffers, and the maximum length of the
string will be determined by the plaorm on which SNAP is running. See the plaorm-specific
parameters in the SNAP Reference Manual for more details. (Note – built-in funcons slice/concat/rpc
enforce smaller limits on what they can do with strings.)
• tuple – A tuple is a read-only container of data elements, e.g., (1,'A',True). SNAPpy tuples must be global
in scope and cannot be used outside the scope of a local script. You cannot pass them as parameters in
RPC calls to other nodes. Each element in a tuple can be any supported data type, including another
tuple. However there are restricons on the prinng of nested tuples. (See the details about prinng
later in this document.)
• funcon – A funcon is a user-defined subroune invoked from elsewhere in your script, or by RPC call
from another node.
SNAP® Network Operang System 13