The Python interactive shell echos the results of expressions using the repr()
function, but print
uses str()
to convert values to a string.
In both cases sum()
produces the exact same result, but in your first sample, you see the interpreter print the output with repr()
, in your second result you used print
and the result was converted to a string with str()
:
>>> import datetime
>>> tote = datetime.timedelta(0, 25200), datetime.timedelta(0, 25200)
>>> brac = sum(tote, datetime.timedelta(0))
>>> brac
datetime.timedelta(0, 50400)
>>> print brac
14:00:00
>>> repr(brac)
'datetime.timedelta(0, 50400)'
There is nothing else you need to do; you already have the same result assigned to brac
.