Specifications
• long – A long is an integer with arbitrary length (potentially exceeding the range of an int).
• complex – A complex is a number with an imaginary component.
• list – A list is an ordered collection of elements.
• dict – A dict is an unordered collection of pairs of keyed elements.
• set – A set is an unordered collection of unique elements.
• User-defined objects (class types)
Keywords
The following Python reserved identifiers are supported in SNAPpy:
• and • break • continue • def • elif • else
• from • global • if • import • is • not
• or • pass • print • return • while
The following identifiers are reserved, but not yet supported in SNAPpy:
• as • assert • class • del • except • exec
• finally • for • in • lambda • raise • try
• with • yield
Operators
SNAPpy supports all Python operators, with the exception of floor (//) and power (**).
+ - * / %
<< >> & | ^ ~
< > <= >= == != <>
Slicing
Slicing is supported for string and tuple data types. For example, if x is “ABCDE” then x[1:4] is
“BCD”.
Concatenation
Concatenation is supported for string data types. For example, if x = “Hello” and y = “, world” then x
+ y is “Hello, world”. String multiplication is not supported. You cannot use
3 * "Hello! " to get
"Hello! Hello! Hello! " in SNAPpy.
Subscripting
Subscripting is supported for string and tuple data types. For example, if x = (‘A’,’B’,’C’) then x[1] =
‘B’.
NOTE – Prior to version 2.2, there was only a single “string buffer” for each type of string operation
(slicing, concatenation, subscripting, etc.). Subsequent operations of that same type would overwrite
previous results. Version 2.2 replaces the fixed string buffers with a small pool of string buffers,
usable for any operation. This allows scripts like the following to now work correctly:
A = B + C # for this example, all variables are strings
D = E + F
SNAP Reference Manual Document Number 600-0007K Page 23 of 202