[Types-sig] updated proposal (fwd)

Greg Stein gstein@lyra.org
Wed, 5 Jan 2000 15:43:56 -0800 (PST)


On Thu, 6 Jan 2000, skaller wrote:
>...
> More precisely: b is a string from the point at which b is 
> bound to the checked expression, at least until:
> 
> 	1) 'end of block'
> 	2) An exec statement is seen
> 	3) An assignment to b
> 	4) If b is global, then a function call
>      	5) the module dictionary is fiddled with	

hehe... then I guess you haven't seen code like this:

  def f():
    a = 5
    g()
    print a
  def g():
    try:
      raise 'hi'
    except:
      t, v, tb = sys.exc_info()
      print tb.tb_frame.f_back.f_locals['a']
  f()


Due to some sneaky behavior in Python, you can't actually change the
locals through that dictionary. Python keeps a separate "fast locals"
structure. There are cases where Python moves locals back and forth
between the dictionary and the fast locals, but I don't recall those
rules.

But there may be a way for another function to affect a function's
locals... hehe.

Of course, we don't have to worry about it because I can bet you that
Guido would be completely opposed to programs doing that :-)

[ actually, there should be a way, so that Python debuggers can alter
  locals... ]

>... rest of note ...

I agree completely. Well-stated.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/