Skip to content
Advertisement

Will the function in python for loop be executed multiple times?

Say I have the following class with a method returning a list:

JavaScript

If I loop over the list returned fro the method, as follows:

JavaScript

Inside the for loop, will c.f() be executed multiple times? If yes, in order to get it once, do I have to do assignment outside of the loop, or there is some trivial way?

Advertisement

Answer

JavaScript

Seems the answer is no.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement