Newbie: can't devide by function()

Sven Brandt sven_NOSPAM at manastar.de
Mon Mar 24 17:19:24 CET 2003


Hi,

I am trying to wirte a script that that first summs up some counters and 
than calculates the fraction of the total ammount for each object.

Funktion sum is fine. The funktion percent does not return anything. If 
I change

"fraction=i.counter / summ()" to
"fraction=i.counter * summ()"

I get a result.

Question: Why can I multiply by the funktion sum but not devide by the 
function sum? (for sum !=0)

Regards
Sven


Script:
def summ():

"""iterate over some Objects and add up their properties
      'counter'(type=int) """

   total_number=0
   for i in container.objectValues(['Folder']):
     total_number= total_numer + i.counter
   return total_number


def percent():

""" calculate the fraction of each object """

   fraction=0
   for i in container.objectValues(['Folder']):
     fraction=i.counter / summ()
   return fraction

return fraction()





More information about the Python-list mailing list