Peter Otten a écrit : >>>> n = 1 >>>> def f(): > ... global n > ... try: > ... return n > ... finally: > ... n += 1 > ... The same without a global: def f(_n=[0]): try: return _n[0] finally: _n[0] += 1 But yeps, using a generator would be better.