Let's say I have the following class with a method that returns a list:
Class C(): def f(): return [1,2,3]
If I iterate over this method as follows:
c=C() for i in cf(): print i
Inside the for loop will cf () be executed multiple times? If so, in order to get it once, do I need to do the assignment outside the loop, or is there some trivial way?
source share