这是我拥有的代码,但看起来不像是Python。
def __contains__(self, childName):
"""Determines if item is a child of this item"""
for c in self.children:
if c.name == childName:
return True
return False
怎样是最“Python”的方式来完成这个任务?使用lambda过滤函数吗?很少有在线示例实际使用对象列表进行属性比较,它们总是展示如何使用实际字符串列表完成,但这并不太现实。