avoid doing an uneeded import in a function

This commit is contained in:
Benjamin Peterson 2009-11-20 02:56:43 +00:00
parent cef9782810
commit 246ec332fd
1 changed files with 4 additions and 4 deletions

View File

@ -263,7 +263,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
dirs.remove('CVS') # don't visit CVS directories 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 # 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 # 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: if topdown:
yield top, dirs, nondirs yield top, dirs, nondirs
for name in dirs: for name in dirs:
path = join(top, name) new_path = join(top, name)
if followlinks or not islink(path): if followlinks or not islink(new_path):
for x in walk(path, topdown, onerror, followlinks): for x in walk(new_path, topdown, onerror, followlinks):
yield x yield x
if not topdown: if not topdown:
yield top, dirs, nondirs yield top, dirs, nondirs