文字列を変更して変更された文字列を返そうとしているだけですが、変数を出力すると「なし」が返されます。
def AddToListTwo(self,IndexPosition):
filename = RemoveLeadingNums(self, str(self.listbox1.get(IndexPosition))) #get the filename, remove the leading numbers if there are any
print filename #this prints None
List2Contents = self.listbox2.get(0, END)
if(filename not in List2Contents): #make sure the file isn't already in list 2
self.listbox2.insert(0, filename)
def RemoveLeadingNums(self, words):
if(isinstance(words,str)):
match = re.search(r'^[0-9]*[.]',words)
if match: #if there is a match, remove it, send it through to make sure there aren't repeating numbers
RemoveLeadingNums(self, re.sub(r'^[0-9]*[.]',"",str(words)).lstrip())
else:
print words #this prints the value correctly
return words
if(isinstance(words,list)):
print "list"
編集 - 複数の人が、一致する場合は値を返さないとコメントしています。あるなら返したくない。繰り返している可能性があります (例: 1.2. itema)。したがって、本質的に再帰を使用してそれを削除し、値を返したいと思いました