我已经使用这个程序有一段时间了,坚持下去似乎很乏味,但我正在运行我的代码以pylint
进行锻炼,我收到错误R0912: 69,0:process_ancestors: Too many branches (7/6) . 我想知道是否有人能够帮助我缩小这个功能,因为它对我来说似乎是最简单的形式......
def process_ancestors(relation_dict, name):
'''Figures out who the ancestors are'''
output_str = ''
name_found = search_name(relation_dict, name)
if not name_found:
output_str = "Unknown person"
else:
ancestor_list = []
person = name
while True:
person = find_parent(relation_dict, person)
if person == None:
break
else:
ancestor_list.append(person)
if ancestor_list:
output_str = ", ".join(ancestor_list)
else:
output_str = "No known ancestors"
return output_str
为你的帮助干杯!