variable scope question?

globalrev skanemupp at yahoo.se
Tue May 13 14:41:58 EDT 2008


http://mail.python.org/pipermail/python-list/2003-October/233435.html

why isnt it printing a in the second(second here, last one in OP)
example before complaining?

def run():
  a = 1
  def run2(b):
    a = b
    print a
  run2(2)
  print a
run()

def run():
  a = 1
  def run2(b):
    print a
    a = b
  run2(2)
  print a
run()



More information about the Python-list mailing list