python dynamic scoping question

Julia Goolia juliagoolia301 at hotmail.com
Sun Apr 20 19:13:34 EDT 2003


Hi,

I have a question regarding scoping in python.  I wish to have some
mechanism which puts variables at a function level scope into the
global scope, dynamically.  I cannot alter my design.

For example, I want this to work:

def f():
  def g():
    x = 5
  g()
  print x
f()

I want to be able to see x in f, event though it was assigned in a
lower scope, g.

Thank you for your time.




More information about the Python-list mailing list