What happens to module's variables after a "from module import" ?

ast nomail at com.invalid
Tue Nov 7 10:39:56 EST 2017


Hello

Here is my module tmp.py:

a=0

def test():
    global a
    print(a)
    a+=1

If I import function "test" from module "tmp" with:

>>> from tmp import test

it works

>>> test()
0
>>> test()
1

But where variable "a" is located ? I can't find it anywhere


Regards









More information about the Python-list mailing list