Newbie: can't devide by function()

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


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)


def summ():

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

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

def percent():

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

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

return fraction()

More information about the Python-list mailing list