all Long constants have an L suffix, not l;
added an output() function to move the I/O out of the algorithm
diff --git a/Demo/scripts/pi.py b/Demo/scripts/pi.py
index 74a66a7..832aedc 100755
--- a/Demo/scripts/pi.py
+++ b/Demo/scripts/pi.py
@@ -11,20 +11,23 @@
 import sys
 
 def main():
-	k, a, b, a1, b1 = 2l, 4l, 1l, 12l, 4l
+	k, a, b, a1, b1 = 2L, 4L, 1L, 12L, 4L
 	while 1:
 		# Next approximation
-		p, q, k = k*k, 2l*k+1l, k+1l
+		p, q, k = k*k, 2L*k+1L, k+1L
 		a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
 		# Print common digits
 		d, d1 = a/b, a1/b1
-		#print a, b, a1, b1
 		while d == d1:
-			# Use write() to avoid spaces between the digits
-			sys.stdout.write(`int(d)`)
-			# Flush so the output is seen immediately
-			sys.stdout.flush()
-			a, a1 = 10l*(a%b), 10l*(a1%b1)
+			output(d)
+			a, a1 = 10L*(a%b), 10L*(a1%b1)
 			d, d1 = a/b, a1/b1
 
+def output(d):
+	# Use write() to avoid spaces between the digits
+	# Use int(d) to avoid a trailing L after each digit
+	sys.stdout.write(`int(d)`)
+	# Flush so the output is seen immediately
+	sys.stdout.flush()
+
 main()