|
From: <mh...@us...> - 2012-12-06 09:24:17
|
Revision: 325
http://gnuplot-py.svn.sourceforge.net/gnuplot-py/?rev=325&view=rev
Author: mhagger
Date: 2012-12-06 09:24:06 +0000 (Thu, 06 Dec 2012)
Log Message:
-----------
Add Python 2.x/3.x compatibility hack for raw_input.
Modified Paths:
--------------
trunk/_Gnuplot.py
trunk/demo.py
trunk/test.py
Modified: trunk/_Gnuplot.py
===================================================================
--- trunk/_Gnuplot.py 2012-12-06 09:23:50 UTC (rev 324)
+++ trunk/_Gnuplot.py 2012-12-06 09:24:06 UTC (rev 325)
@@ -14,6 +14,14 @@
import sys, string, types
+
+try:
+ # For Python 2.x/3.x compatibility:
+ input = raw_input
+except NameError:
+ pass
+
+
import gp, PlotItems, termdefs, Errors
@@ -377,7 +385,7 @@
sys.stderr.write('Press C-d to end interactive input\n')
while 1:
try:
- line = raw_input('gnuplot>>> ')
+ line = input('gnuplot>>> ')
except EOFError:
break
self(line)
Modified: trunk/demo.py
===================================================================
--- trunk/demo.py 2012-12-06 09:23:50 UTC (rev 324)
+++ trunk/demo.py 2012-12-06 09:24:06 UTC (rev 325)
@@ -15,6 +15,14 @@
from numpy import *
+
+try:
+ # For Python 2.x/3.x compatibility:
+ input = raw_input
+except NameError:
+ pass
+
+
# If the package has been installed correctly, this should work:
import Gnuplot, Gnuplot.funcutils
@@ -31,7 +39,7 @@
# Plot a list of (x, y) pairs (tuples or a numpy array would
# also be OK):
g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
- raw_input('Please press return to continue...\n')
+ input('Please press return to continue...\n')
g.reset()
# Plot one dataset from an array and one via a gnuplot function;
@@ -50,7 +58,7 @@
g.ylabel('x squared')
# Plot a function alongside the Data PlotItem defined above:
g.plot(Gnuplot.Func('x**2', title='calculated by gnuplot'), d)
- raw_input('Please press return to continue...\n')
+ input('Please press return to continue...\n')
# Save what we just plotted as a color postscript file.
@@ -61,7 +69,7 @@
g.ylabel('x^2') # take advantage of enhanced postscript mode
g.hardcopy('gp_test.ps', enhanced=1, color=1)
print('\n******** Saved plot to postscript file "gp_test.ps" ********\n')
- raw_input('Please press return to continue...\n')
+ input('Please press return to continue...\n')
g.reset()
# Demonstrate a 3-d plot:
@@ -89,7 +97,7 @@
# binary data. Change this to `binary=1' (or omit the binary
# option) to get the advantage of binary format.
g.splot(Gnuplot.GridData(m,x,y, binary=0))
- raw_input('Please press return to continue...\n')
+ input('Please press return to continue...\n')
# plot another function, but letting GridFunc tabulate its values
# automatically. f could also be a lambda or a global function:
@@ -97,7 +105,7 @@
return 1.0 / (1 + 0.01 * x**2 + 0.5 * y**2)
g.splot(Gnuplot.funcutils.compute_GridData(x,y, f, binary=0))
- raw_input('Please press return to continue...\n')
+ input('Please press return to continue...\n')
# Explicit delete shouldn't be necessary, but if you are having
# trouble with temporary files being left behind, try uncommenting
Modified: trunk/test.py
===================================================================
--- trunk/test.py 2012-12-06 09:23:50 UTC (rev 324)
+++ trunk/test.py 2012-12-06 09:24:06 UTC (rev 325)
@@ -18,6 +18,13 @@
import numpy
try:
+ # For Python 2.x/3.x compatibility:
+ input = raw_input
+except NameError:
+ pass
+
+
+try:
import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils
except ImportError:
# kludge in case Gnuplot hasn't been installed as a module yet:
@@ -32,7 +39,7 @@
def wait(str=None, prompt='Press return to show results...\n'):
if str is not None:
print(str)
- raw_input(prompt)
+ input(prompt)
def main():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|