diff python/moving.py @ 978:184f1dd307f9

corrected print and exception statements for Python 3
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 08 Feb 2018 05:53:50 -0500
parents 4f32d82ca390
children 51d8406b2489
line wrap: on
line diff
--- a/python/moving.py	Tue Feb 06 11:50:43 2018 -0500
+++ b/python/moving.py	Thu Feb 08 05:53:50 2018 -0500
@@ -114,7 +114,7 @@
             if isinstance(i, int):
                 return self.first+i
             else:
-                raise TypeError, "Invalid argument type."
+                raise TypeError("Invalid argument type.")
             #elif isinstance( key, slice ):
 
     def __iter__(self):
@@ -697,7 +697,7 @@
         elif isinstance(i, slice):
             return Trajectory([self.positions[0][i],self.positions[1][i]])
         else:
-            raise TypeError, "Invalid argument type."
+            raise TypeError("Invalid argument type.")
 
     def __str__(self):
         return ' '.join([self.__getitem__(i).__str__() for i in xrange(self.length())])
@@ -792,7 +792,7 @@
     def add(self, traj2):
         '''Returns a new trajectory of the same length'''
         if self.length() != traj2.length():
-            print 'Trajectories of different lengths'
+            print('Trajectories of different lengths')
             return None
         else:
             return Trajectory([[a+b for a,b in zip(self.getXCoordinates(),traj2.getXCoordinates())],
@@ -801,7 +801,7 @@
     def subtract(self, traj2):
         '''Returns a new trajectory of the same length'''
         if self.length() != traj2.length():
-            print 'Trajectories of different lengths'
+            print('Trajectories of different lengths')
             return None
         else:
             return Trajectory([[a-b for a,b in zip(self.getXCoordinates(),traj2.getXCoordinates())],
@@ -1048,7 +1048,7 @@
         if isinstance(i, int):
             return [self.positions[0][i], self.positions[1][i], self.lanes[i]]
         else:
-            raise TypeError, "Invalid argument type."
+            raise TypeError("Invalid argument type.")
             #elif isinstance( key, slice ):
 
     def getSCoordinates(self):
@@ -1200,7 +1200,7 @@
                 obj.velocities = self.velocities.getTrajectoryInInterval(trajectoryInterval)
             return obj
         else:
-            print 'The object does not exist at '+str(inter)
+            print('The object does not exist at {}'.format(inter))
             return None
 
     def getObjectsInMask(self, mask, homography = None, minLength = 1):
@@ -1874,7 +1874,7 @@
                 mismatches.append(previousMatches[a])
         if debug: 
             for mm in set(mismatches):
-                print type(mm), mm.getNum()
+                print('{} {}'.format(type(mm), mm.getNum()))
         # some object mismatches may appear twice
         mme += len(set(mismatches))