Is there really no way to access the iterator object or its state from inside a for-loop?
Using pdb
or ipdb
for example, I can loop over and over again with n
, but not see in which iteration I am (ex post, I mean; of course I could use enumerate, but only before starting the debugger).
def
creates an object, and for
does the same, doesn't it? But the function has a name - and the iterator has not, is not accessible in memory? By the way, is the function accessible from within its body without knowing the name?
(The answers to questions Python: access to iterator-object in for-loops and Iterate again within the for loop suggest that it's not possible, but it seems very strange, I was used to being able to inspect anything in python.)