我正在讨论许多包含相同源代码的类似Makefiles。我试图找出一个特定的源文件中 多少项目存在我想是这样的:。
foo.c的4 projA,projB,projC,projD]
bar.c 1 projC]
似乎我需要为每个makefile创建一个新的lstOfProjects,并且所有'我正在做的是删除它。 我已经尝试了很多其他的方法 元组可以有一个列表作为它的一个元素?带有列表作为维之一的多维列表
for file in listOf Makefiles
for line in Makeifle
find code file (.c or .h)
try:
index = lstFilenames.index(strFilename) # to determine if I have seen this file name yet
# Yes the file name is already in list
lstOfFile = lstProjectNames[index] # get list of projects that this file is seen in
try:
fileIndex = lstOfFile.index(myProject) # check to see if the project is in the project list
except: # project not in list
lstCount[index] +1 # add one to count - I am counting the number of projects this file appears
lstOfProjects.append(myProject) # append the new project to list
except: # file name not found in list
lstFilenames.append (strFilename) # put file in file name list
lstCount.append(1) # set count to one
lstOfProjects.append(myProject) # add project name to project list
#************************************************************************** End of makefile
lstProjectNames.append(lstOfProjects) # add project list to this list (this list in indexed with teh file names and the counts)
del lstOfProjects[:]
甚至消除德尔和移动lstProjectNames.append删除(lstOfProjects )在第二行的最后一行除外。我仍然得到不正确的答案。我觉得我无法在我的lstOfProjects中获得新项目列表,就好像myProjects在我获得新文件时从未获得新列表一样。所有这些变量声明为 = [] –