[Prev][Next][Index][Thread]

Re: Closures



[Eric Kidd]
>
> Urgh.  So Python's closures are still broken:
There is simply another idiomatic way to get the same:

class counter:
  def __init__(self):
     self.n = 0
  def __call__(self):
     self.n = self.n + 1
     return self.n

c=counter()
print c()
print c()







Follow-Ups: References: