AttributeError: Objekt 'NoneType' hat kein Attribut 'append'
Ich habe ein seltsames Problem mit der Python-Übergabe einer Liste als Parameter an eine Funktion. Hier ist der Code:
def foobar(depth, top, bottom, n=len(listTop)):
print dir(top)
print top.append("hi")
if depth > 0:
exit()
foobar(depth+1, top.append(listTop[i]), bottom.append(listBottom[i]))
top = bottom = []
foobar(0, top, bottom)
Es heißt "AttributeError: Objekt 'NoneType' hat kein Attribut 'append'", weil top in foobar None ist, obwohl dir (top) eine vollständige Attribut- und Methodenliste einer Typliste ausgibt. Also, was ist falsch? Ich wollte nur zwei Listen als Parameter an diese rekursive Funktion übergeben.