I would like to know if there is a way to unpack values in a print statement, the same way it is possible to unpack arguments in a function f
This works:
import numpy
er = numpy.array([0.36666667, 0.46666667, 0.43333333, numpy.nan])
l = 0.8
print('%0.3f | %0.3f | %0.3f | %0.3f | %0.1f' % (er[0], er[1], er[2], er[3], l))
# 0.367 | 0.467 | 0.433 | nan | 0.8
However, I would like to avoid multiple er[x]
and instead use something like *er
as in:
def f(a,b,c,d):
return True
print(f(*er))
# True
I tried:
#print('%0.3f | %0.3f | %0.3f | %0.3f | %0.1f' % (*(er, numpy.array([l]))))
But this last line generates "SyntaxError: invalid syntax" error.
Any ideas?