>>> def foo():
... thisIsPrivate = [0]
... def bump():
... thisIsPrivate[0] += 1
... def read():
... return thisIsPrivate[0]
... return bump, read
...
>>> bumper, reader = foo()
>>>
>>> bumper(); bumper(); bumper(); print reader()
3
Now, for even more abuse... It's possible to access and change the list held in the closure "thisIsPrivate". But I'm not going to tell you how!
|