Pythonがリストをパラメーターとして関数に渡すという奇妙な問題があります。コードは次のとおりです。
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)
dir(top)はタイプリストの完全な属性とメソッドリストを出力しますが、foobarではtopがNoneであるため、「AttributeError:'NoneType'オブジェクトには属性'append'がありません」と表示されます。では、何が問題なのですか?この再帰関数にパラメーターとして2つのリストを渡したかっただけです。