Why does 'return self' return None?

前端 未结 4 1966
我寻月下人不归
我寻月下人不归 2021-01-25 06:49

I\'m trying to get the top node of a chain in getTopParent(). When I print out self.name, it indeed prints out the name of the parent instance; however

4条回答
  •  遇见更好的自我
    2021-01-25 07:45

    You need to return self.owner.getTopParent()!

    In Python, you must actually use the return statement to return something from a function, otherwise None is returned.

提交回复
热议问题