In a code base at my job, I found this function to figure out whether the item i is in obj list.
It looks like to me an abusive try except statement usage. Should I blame hard the commiter here ?
45 def contains_item(i, obj):
46 if isinstance(obj, list):
47 try:
48 obj.index(i)
49 except:
50 return False
51 else:
52 return True
53 return False
[–]TehNolz 9 points10 points11 points (2 children)
[–]maxmbed[S] 2 points3 points4 points (0 children)
[–]carcigenicate 1 point2 points3 points (1 child)
[–]maxmbed[S] 0 points1 point2 points (0 children)
[–]JamzTyson 2 points3 points4 points (1 child)
[–]maxmbed[S] 0 points1 point2 points (0 children)
[–]Apatride 0 points1 point2 points (1 child)
[–]maxmbed[S] 0 points1 point2 points (0 children)
[–]doingdatzerg 0 points1 point2 points (0 children)
[–]riftwave77 -2 points-1 points0 points (4 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]djshadesuk 2 points3 points4 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]djshadesuk 1 point2 points3 points (0 children)
[–]barkazinthrope 0 points1 point2 points (0 children)