mobiledream...@gmail.com wrote:
when i call a method foo from another method func. can i access func context
variables or locals() from foo
so
def func():
  i=10
  foo()

in foo, can i access func's local variables on in this case i

As others have already pointed out, this is a really bad idea.
Instead you can do:


def func():
  i = 10
  i = foo(i)

def foo(i):
  i = i + 1
  return i

Sincerely,
Albert

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to