I have a.py which the code is:
#!/usr/bin/env python
#coding=utf-8
def aaa(p):
m=1
n=2
z=m+n+p
return z
Now i want to get "m" and "n" from a.py in another python script, how should I do?
I have a.py which the code is:
#!/usr/bin/env python
#coding=utf-8
def aaa(p):
m=1
n=2
z=m+n+p
return z
Now i want to get "m" and "n" from a.py in another python script, how should I do?
use import a
and then you can use a.m
and a.n
If you dont want to use a.m
the you should import like from a import m
and then use them as they are(m
and n
). But this way isn't the recommended way, as it would confuse you in identifying which variable is from which file.
I just found a similar question. Have a look.