7 Jan
2002
7 Jan
'02
7:23 p.m.
Ben Ocean writes:
... successful ... <dtml-call "REQUEST.set('shipping',_.int(subtotal)*.05)"> ... <dtml-var shipping fmt=dollars-and-cents>
... unsuccessful in action ... Error Type: ValueError Error Value: invalid literal for int(): 126.0 In the first (succesful) case, "shipping" is either a number data type or a string representing an integer. In the second case, you try to convert the string "126.0" into an integer. This fails, because '.' can not be part of such a string.
Solution: convert first to 'float' and then to 'int'. Dieter