Skip to content
This repository

speed.py fixes #184

Merged
merged 2 commits into from over 2 years ago

2 participants

geekless Steve Dekorte
geekless

This fixes the following error:

Traceback (most recent call last):
  File "samples/speed/speed.py", line 81, in 
    Tester().test()
  File "samples/speed/speed.py", line 75, in test
    print "Python version := \"%i.%i.%i %s %i\"" % sys.version_info
TypeError: %d format: a number is required, not sys.version_info

and also makes it run on python 3.

Steve Dekorte stevedekorte merged commit d2105a2 into from
Steve Dekorte
Owner

Thanks geekless

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 12 additions and 8 deletions. Show diff stats Hide diff stats

  1. +12 8 samples/speed/speed.py
20 samples/speed/speed.py
@@ -3,6 +3,10 @@
3 3
4 4 oneMillion = 1000000
5 5
  6 +if sys.version_info >= (3,):
  7 + def xrange(v):
  8 + return range(int(v))
  9 +
6 10 class Tester:
7 11 def foo(self):
8 12 return 1
@@ -12,7 +16,7 @@ def beginTimer(self):
12 16
13 17 def endTimer(self, s):
14 18 mps = 1/(time.time() - self.t1)
15   - print "Python %s := %0.2f" % (s, mps)
  19 + print("Python %s := %0.2f" % (s, mps))
16 20
17 21 def testSlot(self):
18 22 self.beginTimer()
@@ -61,21 +65,21 @@ def testSetLocals(self):
61 65 self.endTimer("localSets ")
62 66
63 67 def test(self):
64   - print ""
  68 + print("")
65 69 self.testLocals()
66 70 self.testSetLocals()
67   - print ""
  71 + print("")
68 72 self.testSlot()
69 73 self.testSetSlot()
70   - print ""
  74 + print("")
71 75 self.testBlock()
72 76 self.testInstantiations()
73 77
74 78 import sys
75   - print "Python version := \"%i.%i.%i %s %i\"" % sys.version_info
76   - print ""
77   - print "// values in millions per second"
78   - print ""
  79 + print("Python version := \"%i.%i.%i %s %i\"" % tuple(sys.version_info))
  80 + print("")
  81 + print("// values in millions per second")
  82 + print("")
79 83
80 84
81 85 Tester().test()

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.