0

I have a variable called A, and two functions, here some code to follow all along:

def foo():
    a = 1
def bar():
    b = a + 2
    print b
foo()
bar()

This is a minimal basic example that explain my situations. Normally, In order to use a in the function bar(), either we mark a as global or we return it, or we can define a outside of the function (global scope). In my case I can't do any one of these.

Is there any other way to be able to access a in bar?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
DeltaWeb
  • 381
  • 2
  • 14

0 Answers0