[Tutor] Re: Recursive search
Thu, 13 Apr 2000 22:32:58 -0400
My thanks to everyone who responded so quickly!
The following was graciously provided by one of
the tutor list members and does exactly what I
wanted (it also made me slap myself a few times
for not catching on to a solution earlier)...
def getConfigs(file, visited = None):
if not os.path.isfile(file):
print "Not a file: %s" % file
if visited == None:
visited = [file]
for line in open(file,"r").readlines():
split = string.split(line)
if len(split) >= 2 and split == "include":
if len(split) != 2:
print "In file %s:" % file
print "Illegal include syntax: %s" % line
# Only recurse if we haven't seen it yet.
if not split in visited:
"I don't want the world... I just want your half."
-- TMBG (Anna Ng)