0
作爲靜態方法實現遞歸函數的正確方法是什麼?作爲靜態方法的遞歸函數
這是我如何使它工作atm。我想知道是否有實現這一目標,留下一個更清潔的內存佔用的「更好」的方式,看起來更Python等
class MyClass(object):
@staticmethod
def recursFun(input):
# termination condition
sth = MyClass().recursFun(subinput)
# do sth
return sth
老實說,如果你正在尋找Pythonic,我只是不會使用'staticmethod' –
你會怎麼做它在oop python? – r2d2oid
我簡直不會讓它成爲類的一部分,並且使其成爲模塊級功能。很難說沒有更多的細節。 –