[Tutor] How to write the __str__ function
s.shall at virginmedia.com
Sun May 14 14:03:02 EDT 2017
I need some advice that I have been embarrased to ask for, because I
think that my error is so elementary.
I have written, as advised by the tutors, a complex program in a topic
that interests me. The program works well and the tests are OK.
Now I want to add a __str__ function, which I thought would be
straightforward. But I cannot get it right.
The code that I have so far is as folows:
" Output from __str__ of POCWP. "
"\n After the first turnover, during the "
"'Population Of Capitals Init' cycle,"
"\n the productivities were raised from 1.0 "
"\n to a specific Unit Constant Capital (UCC) "
"for each specific capital: "
"\n The input value for the mean of UCC "
"was %7.5f" % (self.ucc),
"\n The fractional sigma (FractionalSTD)"
" of UCC that was input was %7.5f " % (self.fractsigma_ucc))
The error message is:
TypeError: __str__ returned non-string (type tuple)
When I omit either or both of the objects; self.ucc or
self.fractsigma_ucc, the code works fine.
So, I guess my code has an error. But I cannot detect the error.
Guidance would be much appreciated.
More information about the Tutor