Say I have the following class with a method returning a list:
class C:
def f(self):
return [1,2,3]
If I loop over the list returned fro the method, as follows:
c = C()
for i in c.f():
print(i)
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?
Seems the answer is no.