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
  • 45,811
  • 27
  • 120
  • 136
DeltaWeb
  • 361
  • 2
  • 13

0 Answers0