[Zope] Greatly Simplifiied Script writing to session: Is
there anything wrong with this?
Dylan Reinhardt
zope@dylanreinhardt.com
Mon, 13 Jan 2003 18:52:27 -0800
At 06:31 PM 1/13/2003, you wrote:
>Is this a vaguery of the script system, and
>should I use
>an external method instead?
It's just an artifact of Python math. When you divide an integer by an
integer, you get an integer. Thus, 40/100 and 25/100 are both equal to 0
and the assignments resulting from these calculations assign the same
values, thus:
session['N_lands']=round(session['N_pond']*(1-(N_irrigation_loss/100)),1)
session['N_soil']=round(session['N_lands']*(1-(N_soil_loss/100)), 1)
... reduces to ...
session['N_lands']=round(session['N_pond']*(1-(0)),1)
session['N_soil']=round(session['N_lands']*(1-(0)), 1)
...and N_soil is dutifully set equal to 1 times the value of N_lands
To fix this, change your declarations at the top to the following:
N_shed_loss=10.0
N_screen_loss=8.0
N_sludge_loss=24.0
N_pond_loss=40.0
N_irrigation_loss=25.0
N_soil_loss=25.0
That should fix it.
HTH,
Dylan