[Python-3000-checkins] r55004 - python/branches/p3yk/Tools/scripts/reindent.py

guido.van.rossum python-3000-checkins at python.org
Fri Apr 27 21:48:25 CEST 2007


Author: guido.van.rossum
Date: Fri Apr 27 21:48:23 2007
New Revision: 55004

Modified:
   python/branches/p3yk/Tools/scripts/reindent.py
Log:
Fix print syntax so this runs using 3.0.


Modified: python/branches/p3yk/Tools/scripts/reindent.py
==============================================================================
--- python/branches/p3yk/Tools/scripts/reindent.py	(original)
+++ python/branches/p3yk/Tools/scripts/reindent.py	Fri Apr 27 21:48:23 2007
@@ -45,8 +45,8 @@
 
 def usage(msg=None):
     if msg is not None:
-        print >> sys.stderr, msg
-    print >> sys.stderr, __doc__
+        print(msg, file=sys.stderr)
+    print(__doc__, file=sys.stderr)
 
 def errprint(*args):
     sep = ""
@@ -85,7 +85,7 @@
 def check(file):
     if os.path.isdir(file) and not os.path.islink(file):
         if verbose:
-            print "listing directory", file
+            print("listing directory", file)
         names = os.listdir(file)
         for name in names:
             fullname = os.path.join(file, name)
@@ -96,7 +96,7 @@
         return
 
     if verbose:
-        print "checking", file, "...",
+        print("checking", file, "...", end=' ')
     try:
         f = open(file)
     except IOError as msg:
@@ -107,24 +107,24 @@
     f.close()
     if r.run():
         if verbose:
-            print "changed."
+            print("changed.")
             if dryrun:
-                print "But this is a dry run, so leaving it alone."
+                print("But this is a dry run, so leaving it alone.")
         if not dryrun:
             bak = file + ".bak"
             if os.path.exists(bak):
                 os.remove(bak)
             os.rename(file, bak)
             if verbose:
-                print "renamed", file, "to", bak
+                print("renamed", file, "to", bak)
             f = open(file, "w")
             r.write(f)
             f.close()
             if verbose:
-                print "wrote new", file
+                print("wrote new", file)
     else:
         if verbose:
-            print "unchanged."
+            print("unchanged.")
 
 def _rstrip(line, JUNK='\n \t'):
     """Return line stripped of trailing spaces, tabs, newlines.


More information about the Python-3000-checkins mailing list