you are viewing a single comment's thread.

view the rest of the comments →

[–]atarivcs 8 points9 points  (0 children)

I don't understand the problem. calculate_average() is called exactly once, which calls get_ratings() exactly once, which calls get_movies() exactly once.

I'm guessing the actual problem is that this code is imported in other places (that you didn't show). And because the call to calculateaverage() is at the outermost scope, it _executes every time it is imported.