nested scopes in IDLE? (2.1)
Kirby Urner
urner at alumni.princeton.edu
Mon Jun 4 00:55:42 EDT 2001
I can get the nested scopes feature to work in
modules of course, using the
from __future__ import nested_scopes
thing, but if I just boot IDLE and try to write
the following compose function, it errors out:
def compose(f,g):
return lambda f,g,x: f(g(x))
There's the old workaround from pre-nested scopes
Pythons:
def compose(f,g):
"""with thanks to Dustin Mitchell"""
return lambda _f=f,_g=g,x: _f(_g(x))
but that's what we want to get away from, and do,
in 2.1 -- but apparently not when entering defs
interactively in IDLE (vs. in saved .py files).
Perhaps issuing
>>> from __future__ import nested_scopes
in IDLE has no effect because we're already into
it too far by that time (whatever that means) i.e.
this statement has to happen at "the top". Perhaps
there's a source code tweek I could make to my
IDLE which includes the nested scopes feature by
default?
Clues?
Kirby
CC by email please: pdx4d at teleport.com or the above
More information about the Python-list
mailing list