On Jun 8, 10:40 am, Sean Farrow <[EMAIL PROTECTED]> wrote:
> Hi:
> I have the folling code:
>         def parseTime(self, time):
>                 minutes =int(float(time)/60)
>                 seconds =int(float(time)-minutes*60)
>                 minutes =str(minutes)
>                 seconds =str(minutes)
> the statements that convert the minutes and seconds variables
> str(minutes) and str(seconds) don't seem to be working.
> Any idea why?
> is there any other way of doing this and perhaps using the $d
> interpolation operator?
> sean.

The divmod builtin function is your friend here.

def parseTime(time):
    seconds = float(time)
    minutes,seconds = divmod(seconds,60)
    return "%02d:%06.3f" % (minutes,seconds) # just guessing

divmod divides the first argument by the second, and returns the tuple
(quotient,remainder).

-- Paul

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to