In Tex, we have the count variables that get automatically updated each time there is a call to reference, that way the figure counter goes up automatically.
I wanted to do something similar in python for counters, for example, each time I need the counter it already has the new value without me needing to add
A+=1
Thanks
Use
itertools.count(), this is an iterator so use thenext()function the advance the object to the next value:You can create a lambda to wrap the function:
Or use a
functools.partial()object:Then call the object each time: