datetime.timedelta division confusion

S

skip

Running from Subversion, I see confusing (to me) behavior related to
division of datetime.timedelta objects by integers:

% python
Python 2.6a0 (trunk:57277:57280M, Aug 28 2007, 17:44:49)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last):
datetime.timedelta(0, 43200)

When I run the interpreter under gdb's control with a breakpoint set in
delta_divide, the breakpoint is not reached in the first case, but it is in
the second. Is there something amiss with division of timedelta objects by
ints or am I just missing something?

Skip
 
A

Arnaud Delobelle

Running from Subversion, I see confusing (to me) behavior related to
division of datetime.timedelta objects by integers:

% python
Python 2.6a0 (trunk:57277:57280M, Aug 28 2007, 17:44:49)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
datetime.timedelta(0, 43200)

When I run the interpreter under gdb's control with a breakpoint set in
delta_divide, the breakpoint is not reached in the first case, but it is in
the second. Is there something amiss with division of timedelta objects by
ints or am I just missing something?

Skip

Try d // 2 ?
It may be that v2.6 considers / as __truediv__ and not __div__.

I can reproduce this behaviour on 2.4:

daffodil:~ arno$ python2.4
Python 2.4.3 (#1, Oct 20 2006, 12:58:47)
[GCC 4.0.1 (Apple Computer, Inc. build 5247)] on darwin
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and
'int'
HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top