PrintingΒΆ

SNAPpy also supports a print statement. Normally, each line of printed output appears on a separate line. If you do not want to automatically advance to the next line (if you do not want an automatic Carriage Return and Line Feed), end your print statement with a comma (,) character:

print "line 1"
print "line 2"
print "line 3 ",
print "and more of line 3"
print "value of x is ", x, " and y is ", y

Printing multiple elements on a single line in SNAPpy produces a slightly different output from how the output appears when printed from Python. Python inserts a space between elements, where SNAPpy does not.

SNAPpy also imposes some restrictions on the printing of nested tuples. You may nest tuples; however, printing of nested tuples will be limited to three layers deep. The following tuple:

(1,'A',(2,'b',(3,'Gamma',(4,'Ansuz'))))

will print as:

(1,'A',(2,'b',(3,'Gamma',(...

SNAPpy also handles string representations of tuples in a slightly different way from Python. Python inserts a space after the comma between items in a tuple, while SNAPpy does not pad with spaces, in order to make better use of its limited string-processing space.