Why would you change the Python scoping rules, instead of using the
function attributes, available from release 2.1 (PEP 232) ?
For example, you may write:
def incgen(start, inc):
def incrementer():
incrementer.a += incrementer.b
return incrementer.a
incrementer.a = start - inc
incrementer.b = inc
return incrementer
f = incgen(100, 2)
g = incgen(200, 3)
for i in range(5):
print f(), g()
The result is:
100 200
102 203
104 206
106 209
108 212
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com