File: python3.patch

package info (click to toggle)
mathomatic 16.0.5-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,192 kB
  • sloc: ansic: 22,029; makefile: 340; sh: 319; python: 96; awk: 39
file content (149 lines) | stat: -rw-r--r-- 4,188 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Description: update python scripts for python3
Author: tony mancill <tmancill@debian.org>

--- a/primes/matho-sum
+++ b/primes/matho-sum
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 # Python program to sum many large integers separated by spaces or newlines.
 # The integers to sum may be entered on the command-line or into standard input.
@@ -12,13 +12,13 @@
 	# read stdin if no command line args
 	while True:
 		try:
-			input_line = raw_input()
+			input_line = input()
 		except:
 			break;
-		for s in string.split(input_line):
+		for s in input_line.split():
 			sum += int(s)
 else:
 	# sum together the command-line args
 	for arg in args:
 		sum += int(arg)
-print sum
+print(sum)
--- a/primes/matho-mult
+++ b/primes/matho-mult
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 # Python program to multiply many large integers separated by spaces or newlines.
 # The integers to multiply may be entered on the command-line or into standard input.
@@ -15,13 +15,13 @@
 	# read stdin if no command line args
 	while True:
 		try:
-			input_line = raw_input()
+			input_line = input()
 		except:
 			break;
-		for s in string.split(input_line):
+		for s in input_line.split():
 			prod *= int(s)
 else:
 	# multiply together the command-line args
 	for arg in args:
 		prod *= int(arg)
-print prod
+print(prod)
--- a/primes/primorial
+++ b/primes/primorial
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 # This is a Python program to display large primorials.
 # A primorial is the product of all primes up to the given number.
@@ -16,11 +16,11 @@
 import sys
 
 def usage(ev):
-	print "This program calculates large primorials."
-	print
-	print "Usage: %s integers" % os.path.basename(sys.argv[0])
-	print
-	print "A primorial is the product of all primes up to the given number."
+	print("This program calculates large primorials.")
+	print()
+	print("Usage: %s integers" % os.path.basename(sys.argv[0]))
+	print()
+	print("A primorial is the product of all primes up to the given number.")
 	sys.exit(ev)
 
 def output_primorial(arg):
@@ -36,9 +36,9 @@
 	for arg in args:
 		try:
 			if (int(arg) < 1):
-				print >>sys.stderr, "Number too small."
+				print("Number too small.", file=sys.stderr)
 				sys.exit(1)
 		except:
-			print >>sys.stderr, "Positive integer required."
+			print("Positive integer required.", file=sys.stderr)
 			usage(1)
 		output_primorial(arg)
--- a/examples/factorial
+++ b/examples/factorial
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 # This is a Python program to display large factorials and test "fact.py".
 
@@ -8,13 +8,13 @@
 import string
 
 def usage():
-	print "This program calculates large factorials."
-	print "Requires and tests \"fact.py\"."
-	print
-	print "Usage: %s integer_expressions" % os.path.basename(sys.argv[0])
-	print
-	print "The integer expressions should be separated by spaces."
-	print "A factorial is the product of all positive integers <= a given integer."
+	print("This program calculates large factorials.")
+	print("Requires and tests \"fact.py\".")
+	print()
+	print("Usage: %s integer_expressions" % os.path.basename(sys.argv[0]))
+	print()
+	print("The integer expressions should be separated by spaces.")
+	print("A factorial is the product of all positive integers <= a given integer.")
 	sys.exit(2)
 
 args = sys.argv[1:]
@@ -23,8 +23,8 @@
 else:
 	try:
 		num = eval(string.join(args))
-		print "factorial(", num, ") =", factorial(num)
+		print("factorial(", num, ") =", factorial(num))
 	except:
 		for arg in args:
 			num = eval(arg)
-			print "factorial(", num, ") =", factorial(num)
+			print("factorial(", num, ") =", factorial(num))
--- a/examples/fact.py
+++ b/examples/fact.py
@@ -7,7 +7,7 @@
 def factorial(x):
 	"Return x! (x factorial)."
 	if (x < 0 or (x % 1.0) != 0.0):
-		raise ValueError, "Factorial argument must be a positive integer."
+		raise ValueError("Factorial argument must be a positive integer.")
 	if (x == 0):
 		return x + 1
 	d = x
@@ -15,6 +15,6 @@
 		x -= 1
 		temp = d * x
 		if (temp <= d):
-			raise ValueError, "Factorial result too large."
+			raise ValueError("Factorial result too large.")
 		d = temp
 	return d