diff --git a/python/examples/pizza/dump.py b/python/examples/pizza/dump.py index 632e534e8f..ec18cba62e 100644 --- a/python/examples/pizza/dump.py +++ b/python/examples/pizza/dump.py @@ -6,6 +6,10 @@ # certain rights in this software. This software is distributed under # the GNU General Public License. +# for python3 compatibility + +from __future__ import print_function + # dump tool oneline = "Read, write, manipulate dump files and particle attributes" @@ -179,9 +183,7 @@ d.extra(data) extract bond/tri/line list from data # Imports and external programs -from __future__ import print_function - -import sys, commands, re, glob, types +import sys, re, glob, types from os import popen from math import * # any function could be used by set() @@ -222,7 +224,7 @@ class dump: self.flist = [] for word in words: self.flist += glob.glob(word) if len(self.flist) == 0 and len(list) == 1: - raise StandardError,"no dump file specified" + raise StandardError("no dump file specified") if len(list) == 1: self.increment = 0 @@ -247,19 +249,19 @@ class dump: snap = self.read_snapshot(f) while snap: self.snaps.append(snap) - print snap.time, + print(snap.time,end='') sys.stdout.flush() snap = self.read_snapshot(f) f.close() - print + print() # sort entries by timestep, cull duplicates self.snaps.sort(self.compare_time) self.cull() self.nsnaps = len(self.snaps) - print "read %d snapshots" % self.nsnaps + print("read %d snapshots" % self.nsnaps) # select all timesteps and atoms @@ -268,36 +270,36 @@ class dump: # set default names for atom columns if file wasn't self-describing if len(self.snaps) == 0: - print "no column assignments made" + print("no column assignments made") elif len(self.names): - print "assigned columns:",self.names2str() + print("assigned columns:",self.names2str()) elif self.snaps[0].atoms == None: - print "no column assignments made" + print("no column assignments made") elif len(self.snaps[0].atoms[0]) == 5: self.map(1,"id",2,"type",3,"x",4,"y",5,"z") - print "assigned columns:",self.names2str() + print("assigned columns:",self.names2str()) elif len(self.snaps[0].atoms[0]) == 8: self.map(1,"id",2,"type",3,"x",4,"y",5,"z",6,"ix",7,"iy",8,"iz") - print "assigned columns:",self.names2str() + print("assigned columns:",self.names2str()) else: - print "no column assignments made" + print("no column assignments made") # if snapshots are scaled, unscale them if (not self.names.has_key("x")) or \ (not self.names.has_key("y")) or \ (not self.names.has_key("z")): - print "no unscaling could be performed" + print("no unscaling could be performed") elif self.nsnaps > 0: if self.scaled(self.nsnaps-1): self.unscale() - else: print "dump is already unscaled" + else: print("dump is already unscaled") # -------------------------------------------------------------------- # read next snapshot from list of files def next(self): - if not self.increment: raise StandardError,"cannot read incrementally" + if not self.increment: raise StandardError("cannot read incrementally") # read next snapshot in current file using eof as pointer # if fail, try next file @@ -309,15 +311,15 @@ class dump: snap = self.read_snapshot(f) if not snap: self.nextfile += 1 - if self.nextfile == len(self.flist): return -1 + if self.nextfile == len(self.flist): return -1 f.close() - self.eof = 0 - continue + self.eof = 0 + continue self.eof = f.tell() f.close() try: self.findtime(snap.time) - continue + continue except: break # select the new snapshot with all its atoms @@ -415,7 +417,7 @@ class dump: def map(self,*pairs): if len(pairs) % 2 != 0: - raise StandardError, "dump map() requires pairs of mappings" + raise StandardError("dump map() requires pairs of mappings") for i in range(0,len(pairs),2): j = i + 1 self.names[pairs[j]] = pairs[i]-1 @@ -432,15 +434,15 @@ class dump: self.nsnaps -= 1 ndel += 1 else: i += 1 - print "%d snapshots deleted" % ndel - print "%d snapshots remaining" % self.nsnaps + print("%d snapshots deleted" % ndel) + print("%d snapshots remaining" % self.nsnaps) # -------------------------------------------------------------------- # scale coords to 0-1 for all snapshots or just one def scale(self,*list): if len(list) == 0: - print "Scaling dump ..." + print("Scaling dump ...") x = self.names["x"] y = self.names["y"] z = self.names["z"] @@ -468,7 +470,7 @@ class dump: def unscale(self,*list): if len(list) == 0: - print "Unscaling dump ..." + print("Unscaling dump ...") x = self.names["x"] y = self.names["y"] z = self.names["z"] @@ -495,7 +497,7 @@ class dump: # wrap coords from outside box to inside def wrap(self): - print "Wrapping dump ..." + print("Wrapping dump ...") x = self.names["x"] y = self.names["y"] @@ -517,7 +519,7 @@ class dump: # unwrap coords from inside box to outside def unwrap(self): - print "Unwrapping dump ..." + print("Unwrapping dump ...") x = self.names["x"] y = self.names["y"] @@ -539,7 +541,7 @@ class dump: # wrap coords to same image as atom ID stored in "other" column def owrap(self,other): - print "Wrapping to other ..." + print("Wrapping to other ...") id = self.names["id"] x = self.names["x"] @@ -583,12 +585,12 @@ class dump: def sort(self,*list): if len(list) == 0: - print "Sorting selected snapshots ..." + print("Sorting selected snapshots ...") id = self.names["id"] for snap in self.snaps: if snap.tselect: self.sort_one(snap,id) elif type(list[0]) is types.StringType: - print "Sorting selected snapshots by %s ..." % list[0] + print("Sorting selected snapshots by %s ..." % list[0]) id = self.names[list[0]] for snap in self.snaps: if snap.tselect: self.sort_one(snap,id) @@ -616,19 +618,19 @@ class dump: else: f = open(file,"a") for snap in self.snaps: if not snap.tselect: continue - print snap.time, + print(snap.time,end='') sys.stdout.flush() if header: - print >>f,"ITEM: TIMESTEP" - print >>f,snap.time - print >>f,"ITEM: NUMBER OF ATOMS" - print >>f,snap.nselect - print >>f,"ITEM: BOX BOUNDS" - print >>f,snap.xlo,snap.xhi - print >>f,snap.ylo,snap.yhi - print >>f,snap.zlo,snap.zhi - print >>f,"ITEM: ATOMS",namestr + print("ITEM: TIMESTEP",file=f) + print(snap.time,file=f) + print("ITEM: NUMBER OF ATOMS",file=f) + print(snap.nselect,file=f) + print("ITEM: BOX BOUNDS",file=f) + print(snap.xlo,snap.xhi,file=f) + print(snap.ylo,snap.yhi,file=f) + print(snap.zlo,snap.zhi,file=f) + print("ITEM: ATOMS",namestr,file=f) atoms = snap.atoms nvalues = len(atoms[0]) @@ -640,9 +642,9 @@ class dump: line += str(int(atoms[i][j])) + " " else: line += str(atoms[i][j]) + " " - print >>f,line + print(line,file=f) f.close() - print "\n%d snapshots" % self.nselect + print("\n%d snapshots" % self.nselect) # -------------------------------------------------------------------- # write one dump file per snapshot from current selection @@ -651,20 +653,20 @@ class dump: if len(self.snaps): namestr = self.names2str() for snap in self.snaps: if not snap.tselect: continue - print snap.time, + print(snap.time,end='') sys.stdout.flush() file = root + "." + str(snap.time) f = open(file,"w") - print >>f,"ITEM: TIMESTEP" - print >>f,snap.time - print >>f,"ITEM: NUMBER OF ATOMS" - print >>f,snap.nselect - print >>f,"ITEM: BOX BOUNDS" - print >>f,snap.xlo,snap.xhi - print >>f,snap.ylo,snap.yhi - print >>f,snap.zlo,snap.zhi - print >>f,"ITEM: ATOMS",namestr + print("ITEM: TIMESTEP",file=f) + print(snap.time,file=f) + print("ITEM: NUMBER OF ATOMS",file=f) + print(snap.nselect,file=f) + print("ITEM: BOX BOUNDS",file=f) + print(snap.xlo,snap.xhi,file=f) + print(snap.ylo,snap.yhi,file=f) + print(snap.zlo,snap.zhi,file=f) + print("ITEM: ATOMS",namestr,file=f) atoms = snap.atoms nvalues = len(atoms[0]) @@ -676,9 +678,9 @@ class dump: line += str(int(atoms[i][j])) + " " else: line += str(atoms[i][j]) + " " - print >>f,line + print(line,file=f) f.close() - print "\n%d snapshots" % self.nselect + print("\n%d snapshots" % self.nselect) # -------------------------------------------------------------------- # find min/max across all selected snapshots/atoms for a particular column @@ -700,7 +702,7 @@ class dump: # set a column value via an equation for all selected snapshots def set(self,eq): - print "Setting ..." + print("Setting ...") pattern = "\$\w*" list = re.findall(pattern,eq) @@ -718,13 +720,13 @@ class dump: for snap in self.snaps: if not snap.tselect: continue for i in range(snap.natoms): - if snap.aselect[i]: exec ceq + if snap.aselect[i]: exec(ceq) # -------------------------------------------------------------------- # set a column value via an input vec for all selected snapshots/atoms def setv(self,colname,vec): - print "Setting ..." + print("Setting ...") if not self.names.has_key(colname): self.newcolumn(colname) icol = self.names[colname] @@ -732,7 +734,7 @@ class dump: for snap in self.snaps: if not snap.tselect: continue if snap.nselect != len(vec): - raise StandardError,"vec length does not match # of selected atoms" + raise StandardError("vec length does not match # of selected atoms") atoms = snap.atoms m = 0 for i in range(snap.natoms): @@ -767,7 +769,7 @@ class dump: inew = self.names[new] min,max = self.minmax(old) - print "min/max = ",min,max + print("min/max = ",min,max) gap = max - min invdelta = n/gap @@ -798,7 +800,7 @@ class dump: def atom(self,n,*list): if len(list) == 0: - raise StandardError, "no columns specified" + raise StandardError("no columns specified") columns = [] values = [] for name in list: @@ -814,7 +816,7 @@ class dump: for i in range(snap.natoms): if atoms[i][id] == n: break if atoms[i][id] != n: - raise StandardError, "could not find atom ID in snapshot" + raise StandardError("could not find atom ID in snapshot") for j in range(ncol): values[j][m] = atoms[i][columns[j]] m += 1 @@ -829,7 +831,7 @@ class dump: snap = self.snaps[self.findtime(n)] if len(list) == 0: - raise StandardError, "no columns specified" + raise StandardError("no columns specified") columns = [] values = [] for name in list: @@ -957,7 +959,7 @@ class dump: def findtime(self,n): for i in range(self.nsnaps): if self.snaps[i].time == n: return i - raise StandardError, "no step %d exists" % n + raise StandardError("no step %d exists" % n) # -------------------------------------------------------------------- # return maximum box size across all selected snapshots @@ -1006,7 +1008,7 @@ class dump: nbonds = int(f.readline()) item = f.readline() if not re.search("BONDS",item): - raise StandardError, "could not read bonds from dump file" + raise StandardError("could not read bonds from dump file") words = f.readline().split() ncol = len(words) @@ -1029,7 +1031,7 @@ class dump: self.bondflag = 1 self.bondlist = bondlist except: - raise StandardError,"could not read from bond dump file" + raise StandardError("could not read from bond dump file") # request bonds from data object @@ -1045,7 +1047,7 @@ class dump: self.bondflag = 1 self.bondlist = bondlist except: - raise StandardError,"could not extract bonds from data object" + raise StandardError("could not extract bonds from data object") # request tris/lines from cdata object @@ -1059,7 +1061,7 @@ class dump: self.lineflag = 1 self.linelist = lines except: - raise StandardError,"could not extract tris/lines from cdata object" + raise StandardError("could not extract tris/lines from cdata object") # request tris from mdump object @@ -1068,10 +1070,10 @@ class dump: self.triflag = 2 self.triobj = arg except: - raise StandardError,"could not extract tris from mdump object" + raise StandardError("could not extract tris from mdump object") else: - raise StandardError,"unrecognized argument to dump.extra()" + raise StandardError("unrecognized argument to dump.extra()") # -------------------------------------------------------------------- @@ -1105,7 +1107,7 @@ class tselect: snap.tselect = 1 data.nselect = len(data.snaps) data.aselect.all() - print "%d snapshots selected out of %d" % (data.nselect,data.nsnaps) + print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps)) # -------------------------------------------------------------------- @@ -1117,7 +1119,7 @@ class tselect: data.snaps[i].tselect = 1 data.nselect = 1 data.aselect.all() - print "%d snapshots selected out of %d" % (data.nselect,data.nsnaps) + print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps)) # -------------------------------------------------------------------- @@ -1126,7 +1128,7 @@ class tselect: for snap in data.snaps: snap.tselect = 0 data.nselect = 0 - print "%d snapshots selected out of %d" % (data.nselect,data.nsnaps) + print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps)) # -------------------------------------------------------------------- @@ -1142,7 +1144,7 @@ class tselect: snap.tselect = 0 data.nselect -= 1 data.aselect.all() - print "%d snapshots selected out of %d" % (data.nselect,data.nsnaps) + print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps)) # -------------------------------------------------------------------- @@ -1153,12 +1155,12 @@ class tselect: ccmd = compile(cmd,'','single') for i in range(data.nsnaps): if not snaps[i].tselect: continue - exec ccmd + exec(ccmd) if not flag: snaps[i].tselect = 0 data.nselect -= 1 data.aselect.all() - print "%d snapshots selected out of %d" % (data.nselect,data.nsnaps) + print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps)) # -------------------------------------------------------------------- # atom selection class @@ -1205,19 +1207,19 @@ class aselect: if not snap.tselect: continue for i in range(snap.natoms): if not snap.aselect[i]: continue - exec ccmd + exec(ccmd) if not flag: snap.aselect[i] = 0 snap.nselect -= 1 for i in range(data.nsnaps): if data.snaps[i].tselect: - print "%d atoms of %d selected in first step %d" % \ - (data.snaps[i].nselect,data.snaps[i].natoms,data.snaps[i].time) + print("%d atoms of %d selected in first step %d" % \ + (data.snaps[i].nselect,data.snaps[i].natoms,data.snaps[i].time)) break for i in range(data.nsnaps-1,-1,-1): if data.snaps[i].tselect: - print "%d atoms of %d selected in last step %d" % \ - (data.snaps[i].nselect,data.snaps[i].natoms,data.snaps[i].time) + print("%d atoms of %d selected in last step %d" % \ + (data.snaps[i].nselect,data.snaps[i].natoms,data.snaps[i].time)) break else: # one timestep @@ -1225,7 +1227,7 @@ class aselect: snap = data.snaps[n] for i in range(snap.natoms): if not snap.aselect[i]: continue - exec ccmd + exec(ccmd) if not flag: snap.aselect[i] = 0 snap.nselect -= 1 diff --git a/python/examples/pizza/gl.py b/python/examples/pizza/gl.py index 71db5b63e7..765653c983 100644 --- a/python/examples/pizza/gl.py +++ b/python/examples/pizza/gl.py @@ -6,6 +6,9 @@ # certain rights in this software. This software is distributed under # the GNU General Public License. +# for python3 compatibility +from __future__ import print_function + # gl tool oneline = "3d interactive visualization via OpenGL" @@ -73,7 +76,7 @@ g.ldef() default = 0 fill if atom/bond/tri/line has type > # defined properties, is an error from vizinfo import colors access color list -print colors list defined color names and RGB values +print(colors) list defined color names and RGB values colors["nickname"] = [R,G,B] set new RGB values from 0 to 255 140 pre-defined colors: red, green, blue, purple, yellow, black, white, etc @@ -499,7 +502,7 @@ class gl: # add GL-specific info to each bond def reload(self): - print "Loading data into gl tool ..." + print("Loading data into gl tool ...") data = self.data self.timeframes = [] @@ -527,9 +530,9 @@ class gl: self.triframes.append(tris) self.lineframes.append(lines) - print time, + print(time,end='') sys.stdout.flush() - print + print() self.nframes = len(self.timeframes) self.distance = compute_distance(self.boxframes[0]) @@ -651,7 +654,7 @@ class gl: self.w.tkRedraw() self.save(file) - print time, + print(time,end='') sys.stdout.flush() i += 1 n += 1 @@ -690,7 +693,7 @@ class gl: fraction*(self.scale_stop - self.scale_start) self.viewupright() - if n == nstart or self.panflag: self.center = compute_center(box) + if n == nstart or self.panflag: self.center = compute_center(box) if bonds: self.bonds_augment(bonds) @@ -706,11 +709,11 @@ class gl: self.w.tkRedraw() self.save(file) - print n, + print(n,end='') sys.stdout.flush() n += 1 - print "\n%d images" % ncount + print("\n%d images" % ncount) # -------------------------------------------------------------------- @@ -776,11 +779,11 @@ class gl: ncolor = self.vizinfo.nlcolor for line in self.linedraw: itype = int(line[1]) - if itype > ncolor: raise StandardError,"line type too big" + if itype > ncolor: raise StandardError("line type too big") red,green,blue = self.vizinfo.lcolor[itype] glColor3f(red,green,blue) thick = self.vizinfo.lrad[itype] - glLineWidth(thick) + glLineWidth(thick) glBegin(GL_LINES) glVertex3f(line[2],line[3],line[4]) glVertex3f(line[5],line[6],line[7]) @@ -825,7 +828,7 @@ class gl: for bond in self.bonddraw: if bond[10] > bound: continue itype = int(bond[1]) - if itype > ncolor: raise StandardError,"bond type too big" + if itype > ncolor: raise StandardError("bond type too big") red,green,blue = self.vizinfo.bcolor[itype] rad = self.vizinfo.brad[itype] glPushMatrix() @@ -848,7 +851,7 @@ class gl: ncolor = self.vizinfo.ntcolor for tri in self.tridraw: itype = int(tri[1]) - if itype > ncolor: raise StandardError,"tri type too big" + if itype > ncolor: raise StandardError("tri type too big") red,green,blue = self.vizinfo.tcolor[itype] glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,[red,green,blue,1.0]); glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,self.shiny); @@ -906,7 +909,7 @@ class gl: ymin >= ylo and ymax <= yhi and zmin >= zlo and zmax <= zhi: if bond[10] > bound: continue itype = int(bond[1]) - if itype > ncolor: raise StandardError,"bond type too big" + if itype > ncolor: raise StandardError("bond type too big") red,green,blue = self.vizinfo.bcolor[itype] rad = self.vizinfo.brad[itype] glPushMatrix() @@ -938,7 +941,7 @@ class gl: ymin >= ylo and ymax <= yhi and \ zmin >= zlo and zmax <= zhi: itype = int(tri[1]) - if itype > ncolor: raise StandardError,"tri type too big" + if itype > ncolor: raise StandardError("tri type too big") red,green,blue = self.vizinfo.tcolor[itype] glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION, [red,green,blue,1.0]); diff --git a/python/examples/pizza/gnu.py b/python/examples/pizza/gnu.py index 1c6dbee033..7d796d5586 100644 --- a/python/examples/pizza/gnu.py +++ b/python/examples/pizza/gnu.py @@ -6,6 +6,9 @@ # certain rights in this software. This software is distributed under # the GNU General Public License. +# for python3 compatibility +from __future__ import print_function + # gnu tool oneline = "Create plots via GnuPlot plotting program" @@ -172,8 +175,8 @@ class gnu: nvec = len(vectors) for i in range(n): for j in range(nvec): - print >>f,vectors[j][i], - print >>f + print(str(vectors[j][i])+" ",file=f,end='') + print ("",file=f) f.close() # -------------------------------------------------------------------- @@ -350,7 +353,7 @@ class gnu: self.__call__("set key off") cmd = 'plot ' - for i in range(fig.ncurves): + for i in range(int(fig.ncurves)): file = self.file + ".%d.%d" % (self.current,i+1) if len(fig.colors) > i and fig.colors[i]: cmd += "'" + file + "' using 1:2 with line %d, " % fig.colors[i] diff --git a/python/examples/pizza/pdbfile.py b/python/examples/pizza/pdbfile.py index 1713ada043..2ca85b64da 100644 --- a/python/examples/pizza/pdbfile.py +++ b/python/examples/pizza/pdbfile.py @@ -6,6 +6,9 @@ # certain rights in this software. This software is distributed under # the GNU General Public License. +# for python3 compatibility +from __future__ import print_function + # pdb tool oneline = "Read, write PDB files in combo with LAMMPS snapshots" @@ -83,7 +86,7 @@ class pdbfile: elif len(args) == 2: filestr = args[0] self.data = args[1] - else: raise StandardError, "invalid args for pdb()" + else: raise StandardError("invalid args for pdb()") # flist = full list of all PDB input file names # append .pdb if needed @@ -97,14 +100,14 @@ class pdbfile: for i in xrange(len(flist)): if flist[i][-4:] != ".pdb": flist[i] += ".pdb" if len(flist) == 0: - raise StandardError,"no PDB file specified" + raise StandardError("no PDB file specified") self.files = flist else: self.files = [] if len(self.files) > 1 and self.data: - raise StandardError, "cannot use multiple PDB files with data object" + raise StandardError("cannot use multiple PDB files with data object") if len(self.files) == 0 and not self.data: - raise StandardError, "no input PDB file(s)" + raise StandardError("no input PDB file(s)") # grab PDB file from http://rcsb.org if not a local file @@ -112,7 +115,7 @@ class pdbfile: try: open(self.files[0],'r').close() except: - print "downloading %s from http://rcsb.org" % self.files[0] + print("downloading %s from http://rcsb.org" % self.files[0]) fetchstr = "http://www.rcsb.org/pdb/cgi/export.cgi/%s?format=PDB&pdbId=2cpk&compression=None" % self.files[0] urllib.urlretrieve(fetchstr,self.files[0]) @@ -142,20 +145,20 @@ class pdbfile: which,time,flag = self.data.iterator(flag) if flag == -1: break self.convert(f,which) - print >>f,"END" - print time, + print("END",file=f) + print(time,end='') sys.stdout.flush() n += 1 else: for file in self.files: f.write(open(file,'r').read()) - print >>f,"END" - print file, + print("END",file=f) + print(file,end='') sys.stdout.flush() f.close() - print "\nwrote %d datasets to %s in PDB format" % (n,file) + print("\nwrote %d datasets to %s in PDB format" % (n,file)) # -------------------------------------------------------------------- # write series of numbered PDB files @@ -190,7 +193,7 @@ class pdbfile: self.convert(f,which) f.close() - print time, + print(time,end='') sys.stdout.flush() n += 1 @@ -210,12 +213,12 @@ class pdbfile: f = open(file,'w') f.write(open(infile,'r').read()) f.close() - print file, + print(file,end='') sys.stdout.flush() n += 1 - print "\nwrote %d datasets to %s*.pdb in PDB format" % (n,root) + print("\nwrote %d datasets to %s*.pdb in PDB format" % (n,root)) # -------------------------------------------------------------------- # write a single PDB file @@ -280,10 +283,10 @@ class pdbfile: if self.atomlines.has_key(id): (begin,end) = self.atomlines[id] line = "%s%8.3f%8.3f%8.3f%s" % (begin,atom[2],atom[3],atom[4],end) - print >>f,line, + print(line,file=f,end='') else: for atom in atoms: begin = "ATOM %6d %2d R00 1 " % (atom[0],atom[1]) middle = "%8.3f%8.3f%8.3f" % (atom[2],atom[3],atom[4]) end = " 1.00 0.00 NONE" - print >>f,begin+middle+end + print(begin+middle+end,file=f) diff --git a/python/examples/pizza/vmd.py b/python/examples/pizza/vmd.py index 7a49617b4c..fb5095617a 100644 --- a/python/examples/pizza/vmd.py +++ b/python/examples/pizza/vmd.py @@ -6,6 +6,9 @@ # certain rights in this software. This software is distributed under # the GNU General Public License. +# for python3 compatibility +from __future__ import print_function + # vmd tool # Minimalistic VMD embedding for Pizza.py @@ -52,7 +55,7 @@ except: PIZZA_VMDDIR = "/usr/local/lib/vmd" try: from DEFAULTS import PIZZA_VMDDEV except: PIZZA_VMDDEV = "win" try: from DEFAULTS import PIZZA_VMDARCH -except: PIZZA_VMDARCH = "LINUX" +except: PIZZA_VMDARCH = "LINUXAMD64" # try these settings for a Mac #PIZZA_VMDNAME = "vmd" @@ -62,8 +65,8 @@ except: PIZZA_VMDARCH = "LINUX" try: import pexpect except: - print "pexpect from http://pypi.python.org/pypi/pexpect", \ - "is required for vmd tool" + print("pexpect from http://pypi.python.org/pypi/pexpect", \ + "is required for vmd tool") raise # Class definition @@ -109,7 +112,7 @@ class vmd: self.VMD.sendline(command) self.VMD.expect('vmd >') if self.debugme: - print "call+result:"+self.VMD.before + print("call+result:"+self.VMD.before) return # -------------------------------------------------------------------- @@ -127,9 +130,9 @@ class vmd: # turn on debugging info def debug(self,status=True): if status and not self.debugme: - print 'Turning vmd.py debugging ON.' + print('Turning vmd.py debugging ON.') if not status and self.debugme: - print 'Turning vmd.py debugging OFF.' + print('Turning vmd.py debugging OFF.') self.debugme = status # -------------------------------------------------------------------- @@ -141,14 +144,14 @@ class vmd: try: command = raw_input("vmd > ") except EOFError: - print "(EOF)" + print("(EOF)") self.__call__('menu main off') return if command == "quit" or command == "exit": self.__call__('menu main off') return if command == "gopython": - print "gopython not supported here" + print("gopython not supported here") continue self.__call__(command)