Re: [Zope] Float object not callable (newbie question)

2005-05-14 Thread Tino Wildenhain
Am Freitag, den 13.05.2005, 16:06 +0100 schrieb Paul Hendrick:
> hi all,
> I'm trying to write a simple app which takes a name, bank balance,
> interest rate and returns the balance once 1 years interest has been
> added. I'm getting the error that float object is not callable. 
> i can't figure out where i'm going wrong :S
> 
> my code is below(getDetails, showDetails,doStuff.py), thanks for any
> input!
> paul.
> 
> 
> 
> 
> 
>   NAME
>   BALANCE
>   INTEREST RATE
>  
> 
> 
> 
> 

This seems ok.
> --
> 
> 
> 
> 
>  
> 
> 
> 
> 

Why this? 1) your python script can read request just fine. No
 need for clumsy code in ZPT
  2) your code below returns a list, so all you get 
 is the string representation of a list. Works
 but does not look so fine ;)

> --
> years = 1
> newBal = balance( balance*(rate*years))

You call balance as function by using ().
Try your function in the interactive interpreter if 
unsure, e.g. 

balance = 5000
rate = 8 # in percent I assume? You should state that in the form
years = 4

newbalance = balance * (1+rate/100.0) ** years

if you output newbalance, you will see if it does what you want.

if you transfer it into the python script,
replace the assignments with 

balance = context.REQUEST.get("balance",0)
rate = context.REQUEST.get("rate",0)
years = context.REQUEST.get("years",0)

and 

return newbalance

at the end.
(You can also skip the variable and return the
 result of the expression directly)


I'd point the form to itself and make
the output just below it.



thats all.



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Float object not callable (newbie question)

2005-05-13 Thread Brian Hickey
Hi Paul,

- Original Message - 
From: "Paul Hendrick" <[EMAIL PROTECTED]>
To: 
Sent: Friday, May 13, 2005 4:06 PM
Subject: [Zope] Float object not callable (newbie question)


> hi all,
> I'm trying to write a simple app which takes a name, bank balance,
> interest rate and returns the balance once 1 years interest has been
> added. I'm getting the error that float object is not callable.
> i can't figure out where i'm going wrong :S
>
> my code is below(getDetails, showDetails,doStuff.py), thanks for any
> input!
> paul.
>
> 
> 
>
> 
>   NAME
>   BALANCE
>   INTEREST RATE
>  
> 
>
> 
> 
> --
> 
> 
>
> 
>  
> 
>
> 
> 
> --
> years = 1
> newBal = balance( balance*(rate*years))

You seem to be calling a function here called 'balance' which is the name of
the parameter.
Should it not be just:
newBal = balance*(rate*years)


>
> returnList = [name,newBal]
>
> return returnList
>
>

Hope that helps,
Brian

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Float object not callable (newbie question)

2005-05-13 Thread Paul Hendrick
hi all,
I'm trying to write a simple app which takes a name, bank balance,
interest rate and returns the balance once 1 years interest has been
added. I'm getting the error that float object is not callable. 
i can't figure out where i'm going wrong :S

my code is below(getDetails, showDetails,doStuff.py), thanks for any
input!
paul.





  NAME
  BALANCE
  INTEREST RATE
 




--




 




--
years = 1
newBal = balance( balance*(rate*years))

returnList = [name,newBal]

return returnList


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )