I have the following function:
def ex(filter, key, user):
login = user
secret = key
f1 = filter
"..." #many other comands
user = "some text"
key = "some numbers"
filter = "2017/10"
to apply this function I write:
user = "some text"
key = "some numbers"
ex("2010/10",key,user)
This function works without any problems. My question is how can I make the local variables taking values from the global ones? so I want to be able to apply my code just by writing the following:
user = "some text"
key = "some numbers"
ex("2017/10")
Any suggestions?
Update
After wririting the code according to @v Sugumar. Calling the function from shell
>>> import expens as e
>>> user = "XXX"
>>> key = "111"
>>> e.exp("08/2017")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ad\Anaconda4\lib\expens.py", line 29, in exp
userid = user
NameError: name 'user' is not defined
>>>