On 4 August 2011 01:16, David <ld...@gmx.net> wrote: > I got an error message that surprises me. I know how to solve the > problem (couple of parentheses will do), but I would expect Python to > run as the code is presented below. > After all, my_weight is a number that can be multiplied by a float. > I would expect Python to evaluate the expression after the (final) > operator and then having it inserted into the string. > > So I guess my question is this: what is the path that Python follows in > its string formatting operations?
It had my stumped at first but then I saw what was happening. After some experimentation it seems that string formatting first converts my_weight to a string and then multiplies it. And multiplying a string with a float is not possible. Greets Sander _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor