I have basic knowledge in c++ and I got an assignment to read a code it python and rewrite it in c++. I'm not familiar with python so I'm sorry for any newbie Q :).
In the code I see:
before,err = TG.quad(fnx, -N/2, -x)
before_n = before/all
inTime, err = TG.quad(fnx, -x,left)
inTime_n= inTime/all
in the first line, are 'before' and 'err' 2 vars who are assigned to the value from the left?
when I try to run an example for myself:
b,a= 5
print (a,b)
I get the error
"TypeError: 'int' object is not iterable",
what am I missing?
You should have two values for each variables.
I am sure your method is returning two values.
Short answer:
It is simply a shorter way of assigning variables.
Is the same as:
More technical: As TigerhawkT3 says, they are not exactly the same. For example in:
a is 1 and b is 0, Exchanging the values of a and b. This is different from
Where a and b are 1.
On the other hand, if we do:
x is [0, 2]. First assign i, then x[i].
This is covered in the official Python tutorial, under Data Structures > Tuples and Sequences:
Note this portion:
The statement
before,err = TG.quad(fnx, -N/2, -x)
fulfills this requirement, butb,a = 5
does not.