Answer the question
In order to leave comments, you need to log in
How to pass a variable to a python function?
Good day.
How can I pass a variable to the "add_numbers" function from another function.
The difficulty is that the add_numbers function is already returning a different value with eturn jsonify(result=v).
How can I accept a variable in the add_numbers function?
Sample code below
@app.route('/_add_numbers')
def add_numbers():
return jsonify(result=<b>v</b>)
@app.route('/home/')
def home():
v = 1
Answer the question
In order to leave comments, you need to log in
I am not an architecture guru, but why not implement this option:
@app.route('/_add_numbers')
def add_numbers():
_home=get_home()
return jsonify(result=<b>_home</b>)
@app.route('/home/')
def home():
return get_home()
def get_home():
return 1
If I understand you correctly, then:
class Foo:
__data=''
def jsonify(self,param1):
return param1+'_ok'
@property
def add_numbers(self):
return self.jsonify(self.__data)
@add_numbers.setter
def add_numbers(self,value):
self.__data=value
def home():
e=Foo()
e.add_numbers = 'test'
print (e.add_numbers)
home()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question