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

BrunoV bruno.vitorge@pasteur...
Mon Jun 24 12:09:11 CDT 2013


Hello, I'm new to this list and a beginner in python. 
 I'm trying to use datetime module.
to do it simple here is the part of the  code I'm using:

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

If I start ipython with this line:
ipython -pylab -wthread and then  copy paste these lines 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>

I get the same error in Ipython console when Ipython is started without any
option.
So I suppose the error is linked with the use of  pylab option. 
Is it normal that using %run, and  using %cpaste I'm getting the same
behaviour?

How can I get my script working using %run
Thank you very much for your answers.

Regards 



--
View this message in context: http://python.6.x6.nabble.com/running-sum-datetime-timedelta-gives-an-error-but-not-always-tp5022260.html
Sent from the IPython - User mailing list archive at Nabble.com.


More information about the IPython-User mailing list