subrefs = [] i = 0 for j in range(3): i = i + 1 def subref(): print( i ) subrefs.append( subref ) for subref in subrefs: subref()