Iteration within re.sub()?

Fredrik Lundh fredrik at pythonware.com
Tue Dec 14 03:03:17 EST 2004


Bryant Huang wrote:

> Ah beautiful, thank you both, Robert and Mark, for your instant and
> helpful responses. I understand, so the basic idea is to keep a
> variable that is globally accessible and call an external function to
> increment that variable...

accessible for the callback function, that is.

see Mark's example for the right way to do it (using a object to hold
the state, and an object method as the callback -- the latter is known
as a "bound method", and holds a reference to both the data (self) and
the code).

</F> 






More information about the Python-list mailing list