[Python-checkins] r54500 - sandbox/trunk/2to3/fixes/util.py

collin.winter python-checkins at python.org
Wed Mar 21 22:17:52 CET 2007


Author: collin.winter
Date: Wed Mar 21 22:17:48 2007
New Revision: 54500

Modified:
   sandbox/trunk/2to3/fixes/util.py
Log:
Have Name() and Number() take advantage of Leaf's prefix keyword arg.

Modified: sandbox/trunk/2to3/fixes/util.py
==============================================================================
--- sandbox/trunk/2to3/fixes/util.py	(original)
+++ sandbox/trunk/2to3/fixes/util.py	Wed Mar 21 22:17:48 2007
@@ -25,11 +25,9 @@
 
     return Node(syms.atom, target + (ass_leaf.clone(),) + source)
 
-def Name(name, prefix=""):
+def Name(name, prefix=None):
     """Return a NAME leaf"""
-    l = Leaf(token.NAME, name)
-    l.set_prefix(prefix)
-    return l
+    return Leaf(token.NAME, name, prefix=prefix)
 
 def Attr(obj, attr):
     """A node tuple for obj.attr"""
@@ -56,8 +54,8 @@
     """A newline literal"""
     return Leaf(token.NEWLINE, "\n")
 
-def Number(n):
-    return Leaf(token.NUMBER, n)
+def Number(n, prefix=None):
+    return Leaf(token.NUMBER, n, prefix=prefix)
 
 def Subscript(index_node):
     """A numeric or string subscript"""


More information about the Python-checkins mailing list