[ZO-Coll] [ZOC] 294/ 1 Request "unsupported operand type(s) for /"

Collector: NEW Zope.org (the ... zope-web at zope.org
Wed Nov 19 18:00:18 EST 2003


Issue #294 Update (Request) "unsupported operand  type(s) for /"
 Status Pending, functionality/bug medium
To followup, visit:
  http://collector.zope.org/ZopeOrg/294

==============================================================
= Request - Entry #1 by wchris on Nov 19, 2003 6:00 pm

I am going through "The Zope Book" to learn ZOPE and have been trying to run the Interest Rate example in particular the script (python) object. I have gutted most of the lines and now just have this in the Script (python) object:
""" 
Calculate compounding interest.
"""

i = 1 / periods
print i

return printed

When I test the script, I get the page asking for the value for periods. I put in 10. I then get this error:

Error Type: TypeError
Error Value: unsupported operand type(s) for /

I then changed this statement from-
i = 1 / periods
to
i = 1 / 10

it ran but the printed output was 0 and not .1

I am guessing that the variable i needs to be set to something that I don't know about (I have 15+ years of C but 2 days experience of python) Am I doing something wrong? I pasted in the example and expected it to run but ran into this...

By the way, If I change the operand to a * :
i = 1 * periods
it works just fine. It seems that the / is giving me grief.

Thanks....

==============================================================




More information about the Zopeorg-collector mailing list