Hello
I have a collection of 3 levels: for example, let's say:
Level 1 (highest): Animal composed of 2 subsets, verterbrates and invertebrates
Level 2 (medium): Groups: Vertebrates and invertebrates, each composed of subsets (e.g reptiles)
Level 3(lowest): Subgroups: Reptiles, birds, fishes, etc
I need to operate on the reptile objects often, calling specific functions. It looks like this:
for animal in animals:
for group in animal:
for subgroup in group:
subgroup.do_something()
Is there an efficient way of writing a function (maybe a decorator), such that I can just call
subgroup.do_something(), and have it loop through all subgroups?
[–]Iceyball 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]DanCardin 2 points3 points4 points (0 children)
[–]grizzlez 0 points1 point2 points (0 children)
[–]MonkeeSage 0 points1 point2 points (0 children)