[IPython-User] running sum(datetime.timedelta) gives an error!

Bruno Vitorge bruno.vitorge@pasteur...
Fri Jun 21 05:29:44 CDT 2013


Hello I'm trying to use datetime module.
to do it simple here is the code I'm using:

import datetime as dtm
toto = [[dtm.timedelta(0, 25200), dtm.timedelta(0, 3600)]]
print sum(toto)

If I copy paste in Ipython console using %cpaste
everything it is working as expected.

But if I run the file containing this portion of code using the %run 
the_file.py, I get the following error:

TypeError: unsupported operand type(s) for +: 'int' and 'list'
WARNING: Failure executing file: <try.py>

Why I get this behaviour and how can I correct my code to make it work?
Thank you very much for your answers.

Regards


More information about the IPython-User mailing list