CRAZY: First class namespaces
Darrell Gallion
darrell at dorb.com
Mon May 29 16:00:58 EDT 2000
So I got that example wrong :)
And what I was trying to say might work the same as in "C"
dyn(&x, &y)
If I now understand you're saying, the function captures a scope from where
it's defined. Or is given a scope on the fly. So could a function instance
act like a class to produce new functions, each with it's own dynamic scope?
Maybe a default var could be twisted to this use.
def dyn( self=None):
self.x=1
def helper(func):
func()
def test():
x=0
# use dyn like a class
myFunc=dyn(self=locals())
helper(myFunc)
assert(x==1)
More information about the Python-list
mailing list