]> granicus.if.org Git - python/commitdiff
avoid doing an uneeded import in a function
authorBenjamin Peterson <benjamin@python.org>
Fri, 20 Nov 2009 02:56:43 +0000 (02:56 +0000)
committerBenjamin Peterson <benjamin@python.org>
Fri, 20 Nov 2009 02:56:43 +0000 (02:56 +0000)
Lib/os.py

index c41af1ae3cf1872a12e0d3a44e7d2d6d0710e0ef..e8a011337c3980b0e8dd7f2ae0fc8436dd6ba595 100644 (file)
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -263,7 +263,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
             dirs.remove('CVS')  # don't visit CVS directories
     """
 
-    from os.path import join, isdir, islink
+    islink, join, isdir = path.islink, path.join, path.isdir
 
     # We may not have read permission for top, in which case we can't
     # get a list of the files the directory contains.  os.path.walk
@@ -289,9 +289,9 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
     if topdown:
         yield top, dirs, nondirs
     for name in dirs:
-        path = join(top, name)
-        if followlinks or not islink(path):
-            for x in walk(path, topdown, onerror, followlinks):
+        new_path = join(top, name)
+        if followlinks or not islink(new_path):
+            for x in walk(new_path, topdown, onerror, followlinks):
                 yield x
     if not topdown:
         yield top, dirs, nondirs