What's up with rebinding assignment?
mcherm at mcherm.com
Thu Mar 27 18:16:58 CET 2003
Greg Ewing writes:
> > def bind():
> > x = 1
> > def rebind():
> > lexical x
> > x = 2
> > rebind()
> > print x
> This looks a lot neater to me than adding a new assignment
> But I would call it "outer" rather than "lexical".
I'm not yet convinced that allowing this is a good idea -- I
rarely need it and tend to use classes as a workaround in the
rare cases. But IF it's to be done, this feels like the "one
It would certainly clear up an oddity about scopes. Right now
global (module level)
"outer" (nested scopes)
All are readable. built-in is not writable (except with tricks)
on purpose. Global is writable only with global statement.
local is writable always (of course!). But "outer" seems the
odd man out.
-- Michael Chermside
More information about the Python-list