This question has a part a and part b, where b is the what I am trying to achieve, but a is stumbling block.
(a) I have a view function in a React/Flask app that returns a tuple which contains three float values. This tuple is itself a value returned from another function call.
To return this tuple from view function as a response, I first tried to cast this to a string, using str(tuple)
. On the frontend this displayed as the literal tuple, comma separated, (3.0, 6.7, 9.1)
. However when I did:
return '{} {} {}'.format(value1, value2, value3)
I got the string itself on the frontend, without the tuple () and comma separated values. So this part a question is, why does casting to a str, as per first approach, not work in the same way?
(b) In the end, the goal is that I need to return the tuple from the view function in Flask in such a way that I can access each value separately on the front end, so would I be better off trying to convert the tuple to an object? If so, how could I go about handling the tuple returned here to achieve that?